Allow the externalfile scheme to be whitelisted as an allowed scheme for component...
[chromium-blink-merge.git] / components / crash / app / crash_keys_win.h
blob45fa49baacc4abc640cb44bd02decefb5c37769b
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <map>
6 #include <string>
7 #include <vector>
9 #include "base/macros.h"
10 #include "base/synchronization/lock.h"
11 #include "breakpad/src/client/windows/common/ipc_protocol.h"
12 #include "breakpad/src/client/windows/handler/exception_handler.h"
15 namespace base {
16 class CommandLine;
17 } // namespace base
19 namespace crash_reporter {
20 class CrashReporterClient;
23 namespace breakpad {
25 // Manages the breakpad key/value pair stash, there may only be one instance
26 // of this class per process at one time.
27 class CrashKeysWin {
28 public:
29 CrashKeysWin();
30 ~CrashKeysWin();
32 // May only be called once.
33 // |exe_path| is the path to the executable running, which may be used
34 // to figure out whether this is a user or system install.
35 // |type| is the process type, or mode this process is running in e.g.
36 // something like "browser" or "renderer".
37 // |profile_type| is a string describing the kind of the user's Windows
38 // profile, e.g. "mandatory", or "roaming" or similar.
39 // |cmd_line| is the current process' command line consulted for explicit
40 // crash reporting flags.
41 // |crash_client| is consulted for crash reporting settings.
42 google_breakpad::CustomClientInfo* GetCustomInfo(
43 const std::wstring& exe_path,
44 const std::wstring& type,
45 const std::wstring& profile_type,
46 base::CommandLine* cmd_line,
47 crash_reporter::CrashReporterClient* crash_client);
49 void SetCrashKeyValue(const std::wstring& key, const std::wstring& value);
50 void ClearCrashKeyValue(const std::wstring& key);
52 static CrashKeysWin* keeper() { return keeper_; }
54 private:
55 // One-time initialization of private key/value pairs.
56 void SetPluginPath(const std::wstring& path);
57 void SetBreakpadDumpPath(crash_reporter::CrashReporterClient* crash_client);
59 // Must not be resized after GetCustomInfo is invoked.
60 std::vector<google_breakpad::CustomInfoEntry> custom_entries_;
62 typedef std::map<std::wstring, google_breakpad::CustomInfoEntry*>
63 DynamicEntriesMap;
64 base::Lock lock_;
65 // Keeps track of the next index for a new dynamic entry.
66 size_t dynamic_keys_offset_; // Under lock_.
67 // Maintains key->entry information for dynamic key/value entries
68 // in custom_entries_.
69 DynamicEntriesMap dynamic_entries_; // Under lock_.
71 // Stores the sole instance of this class allowed per process.
72 static CrashKeysWin* keeper_;
74 DISALLOW_COPY_AND_ASSIGN(CrashKeysWin);
77 } // namespace breakpad