summaryrefslogtreecommitdiff
path: root/chromium/extensions/common/features/feature_util.h
blob: 342cc666a1987217cf31342e18310d4910ef8070 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef EXTENSIONS_COMMON_FEATURES_FEATURE_UTIL_H_
#define EXTENSIONS_COMMON_FEATURES_FEATURE_UTIL_H_

#include "base/debug/alias.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/strings/string_util.h"

// Writes |message| to the stack so that it shows up in the minidump, then
// crashes the current process.
//
// The prefix "e::" is used so that the crash can be quickly located.
//
// This is provided in feature_util because for some reason features are prone
// to mysterious crashes in named map lookups. For example see crbug.com/365192
// and crbug.com/461915.
#define CRASH_WITH_MINIDUMP(message)                                           \
  {                                                                            \
    std::string message_copy(message);                                         \
    char minidump[BUFSIZ];                                                     \
    base::debug::Alias(&minidump);                                             \
    base::snprintf(minidump, arraysize(minidump), "e::%s:%d:\"%s\"", __FILE__, \
                   __LINE__, message_copy.c_str());                            \
    LOG(FATAL) << message_copy;                                                \
  }

namespace extensions {
namespace feature_util {

// Returns true if service workers are enabled for extension schemes.
// TODO(lazyboy): Remove this function once extension Service Workers
// are enabled by default for a while.
bool ExtensionServiceWorkersEnabled();

}  // namespace feature_util
}  // namespace extensions

#endif  // EXTENSIONS_COMMON_FEATURES_FEATURE_UTIL_H_