OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/mac/mac_util.h" | 6 #include "base/mac/mac_util.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/browser/browser_process.h" | |
11 #import "chrome/browser/ui/cocoa/about_ipc_controller.h" | 10 #import "chrome/browser/ui/cocoa/about_ipc_controller.h" |
| 11 #include "content/public/browser/content_ipc_logging.h" |
12 | 12 |
13 #if defined(IPC_MESSAGE_LOG_ENABLED) | 13 #if defined(IPC_MESSAGE_LOG_ENABLED) |
14 | 14 |
15 @implementation CocoaLogData | 15 @implementation CocoaLogData |
16 | 16 |
17 - (id)initWithLogData:(const IPC::LogData&)data { | 17 - (id)initWithLogData:(const IPC::LogData&)data { |
18 if ((self = [super init])) { | 18 if ((self = [super init])) { |
19 data_ = data; | 19 data_ = data; |
20 // data_.message_name may not have been filled in if it originated | 20 // data_.message_name may not have been filled in if it originated |
21 // somewhere other than the browser process. | 21 // somewhere other than the browser process. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 appCache_ = view_ = utilityHost_ = viewHost_ = plugin_ = | 93 appCache_ = view_ = utilityHost_ = viewHost_ = plugin_ = |
94 npObject_ = devTools_ = pluginProcessing_ = userString1_ = | 94 npObject_ = devTools_ = pluginProcessing_ = userString1_ = |
95 userString2_ = userString3_ = YES; | 95 userString2_ = userString3_ = YES; |
96 } | 96 } |
97 return self; | 97 return self; |
98 } | 98 } |
99 | 99 |
100 - (void)dealloc { | 100 - (void)dealloc { |
101 if (gSharedController == self) | 101 if (gSharedController == self) |
102 gSharedController = nil; | 102 gSharedController = nil; |
103 if (g_browser_process) | 103 content::EnableIPCLogging(false); // just in case... |
104 g_browser_process->SetIPCLoggingEnabled(false); // just in case... | |
105 IPC::Logging::GetInstance()->SetConsumer(NULL); | 104 IPC::Logging::GetInstance()->SetConsumer(NULL); |
106 [super dealloc]; | 105 [super dealloc]; |
107 } | 106 } |
108 | 107 |
109 - (void)awakeFromNib { | 108 - (void)awakeFromNib { |
110 // Running Chrome with the --ipc-logging switch might cause it to | 109 // Running Chrome with the --ipc-logging switch might cause it to |
111 // be enabled before the about:ipc window comes up; accomodate. | 110 // be enabled before the about:ipc window comes up; accomodate. |
112 [self updateVisibleRunState]; | 111 [self updateVisibleRunState]; |
113 | 112 |
114 // We are now able to display information, so let'er rip. | 113 // We are now able to display information, so let'er rip. |
115 bridge_.reset(new AboutIPCBridge(self)); | 114 bridge_.reset(new AboutIPCBridge(self)); |
116 IPC::Logging::GetInstance()->SetConsumer(bridge_.get()); | 115 IPC::Logging::GetInstance()->SetConsumer(bridge_.get()); |
117 } | 116 } |
118 | 117 |
119 // Delegate callback. Closing the window means there is no more need | 118 // Delegate callback. Closing the window means there is no more need |
120 // for the me, the controller. | 119 // for the me, the controller. |
121 - (void)windowWillClose:(NSNotification*)notification { | 120 - (void)windowWillClose:(NSNotification*)notification { |
122 [self autorelease]; | 121 [self autorelease]; |
123 } | 122 } |
124 | 123 |
125 - (void)updateVisibleRunState { | 124 - (void)updateVisibleRunState { |
126 if (IPC::Logging::GetInstance()->Enabled()) | 125 if (IPC::Logging::GetInstance()->Enabled()) |
127 [startStopButton_ setTitle:@"Stop"]; | 126 [startStopButton_ setTitle:@"Stop"]; |
128 else | 127 else |
129 [startStopButton_ setTitle:@"Start"]; | 128 [startStopButton_ setTitle:@"Start"]; |
130 } | 129 } |
131 | 130 |
132 - (IBAction)startStop:(id)sender { | 131 - (IBAction)startStop:(id)sender { |
133 g_browser_process->SetIPCLoggingEnabled( | 132 content::EnableIPCLogging(!IPC::Logging::GetInstance()->Enabled()); |
134 !IPC::Logging::GetInstance()->Enabled()); | |
135 [self updateVisibleRunState]; | 133 [self updateVisibleRunState]; |
136 } | 134 } |
137 | 135 |
138 - (IBAction)clear:(id)sender { | 136 - (IBAction)clear:(id)sender { |
139 [dataController_ setContent:[NSMutableArray array]]; | 137 [dataController_ setContent:[NSMutableArray array]]; |
140 [eventCount_ setStringValue:@"0"]; | 138 [eventCount_ setStringValue:@"0"]; |
141 [filteredEventCount_ setStringValue:@"0"]; | 139 [filteredEventCount_ setStringValue:@"0"]; |
142 filteredEventCounter_ = 0; | 140 filteredEventCounter_ = 0; |
143 } | 141 } |
144 | 142 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 188 } |
191 | 189 |
192 - (void)setDisplayViewMessages:(BOOL)display { | 190 - (void)setDisplayViewMessages:(BOOL)display { |
193 view_ = display; | 191 view_ = display; |
194 } | 192 } |
195 | 193 |
196 @end | 194 @end |
197 | 195 |
198 #endif // IPC_MESSAGE_LOG_ENABLED | 196 #endif // IPC_MESSAGE_LOG_ENABLED |
199 | 197 |
OLD | NEW |