Roll src/third_party/WebKit c63b89c:29324ab (svn 202546:202547)
[chromium-blink-merge.git] / components / crash / content / app / crash_keys_win.h
blob870de77af3357ec9ec783b547edabef4d743aeac
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 #ifndef COMPONENTS_CRASH_CONTENT_APP_CRASH_KEYS_WIN_H_
6 #define COMPONENTS_CRASH_CONTENT_APP_CRASH_KEYS_WIN_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/macros.h"
13 #include "base/synchronization/lock.h"
14 #include "breakpad/src/client/windows/common/ipc_protocol.h"
15 #include "breakpad/src/client/windows/handler/exception_handler.h"
18 namespace base {
19 class CommandLine;
20 } // namespace base
22 namespace crash_reporter {
23 class CrashReporterClient;
26 namespace breakpad {
28 // Manages the breakpad key/value pair stash, there may only be one instance
29 // of this class per process at one time.
30 class CrashKeysWin {
31 public:
32 CrashKeysWin();
33 ~CrashKeysWin();
35 // May only be called once.
36 // |exe_path| is the path to the executable running, which may be used
37 // to figure out whether this is a user or system install.
38 // |type| is the process type, or mode this process is running in e.g.
39 // something like "browser" or "renderer".
40 // |profile_type| is a string describing the kind of the user's Windows
41 // profile, e.g. "mandatory", or "roaming" or similar.
42 // |cmd_line| is the current process' command line consulted for explicit
43 // crash reporting flags.
44 // |crash_client| is consulted for crash reporting settings.
45 google_breakpad::CustomClientInfo* GetCustomInfo(
46 const std::wstring& exe_path,
47 const std::wstring& type,
48 const std::wstring& profile_type,
49 base::CommandLine* cmd_line,
50 crash_reporter::CrashReporterClient* crash_client);
52 void SetCrashKeyValue(const std::wstring& key, const std::wstring& value);
53 void ClearCrashKeyValue(const std::wstring& key);
55 const std::vector<google_breakpad::CustomInfoEntry>& custom_info_entries()
56 const {
57 return custom_entries_;
60 static CrashKeysWin* keeper() { return keeper_; }
62 private:
63 // One-time initialization of private key/value pairs.
64 void SetPluginPath(const std::wstring& path);
65 void SetBreakpadDumpPath(crash_reporter::CrashReporterClient* crash_client);
67 // Must not be resized after GetCustomInfo is invoked.
68 std::vector<google_breakpad::CustomInfoEntry> custom_entries_;
70 typedef std::map<std::wstring, google_breakpad::CustomInfoEntry*>
71 DynamicEntriesMap;
72 base::Lock lock_;
73 // Keeps track of the next index for a new dynamic entry.
74 size_t dynamic_keys_offset_; // Under lock_.
75 // Maintains key->entry information for dynamic key/value entries
76 // in custom_entries_.
77 DynamicEntriesMap dynamic_entries_; // Under lock_.
79 // Stores the sole instance of this class allowed per process.
80 static CrashKeysWin* keeper_;
82 DISALLOW_COPY_AND_ASSIGN(CrashKeysWin);
85 } // namespace breakpad
87 #endif // COMPONENTS_CRASH_CONTENT_APP_CRASH_KEYS_WIN_H_