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