Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: content/browser/mach_broker_mac.cc

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/host_zoom_map.cc ('k') | content/browser/notification_service_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/mach_broker_mac.h" 5 #include "content/browser/mach_broker_mac.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/mach_ipc_mac.h" 10 #include "base/mach_ipc_mac.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/sys_string_conversions.h" 13 #include "base/sys_string_conversions.h"
14 #include "base/threading/platform_thread.h" 14 #include "base/threading/platform_thread.h"
15 #include "content/browser/browser_thread.h" 15 #include "content/browser/browser_thread.h"
16 #include "content/browser/renderer_host/render_process_host.h" 16 #include "content/browser/renderer_host/render_process_host.h"
17 #include "content/common/child_process_info.h" 17 #include "content/common/child_process_info.h"
18 #include "content/common/notification_service.h" 18 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/notification_types.h" 19 #include "content/public/browser/notification_types.h"
20 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
21 21
22 namespace { 22 namespace {
23 // Prints a string representation of a Mach error code. 23 // Prints a string representation of a Mach error code.
24 std::string MachErrorCode(kern_return_t err) { 24 std::string MachErrorCode(kern_return_t err) {
25 return base::StringPrintf("0x%x %s", err, mach_error_string(err)); 25 return base::StringPrintf("0x%x %s", err, mach_error_string(err));
26 } 26 }
27 } // namespace 27 } // namespace
28 28
29 // Required because notifications happen on the UI thread. 29 // Required because notifications happen on the UI thread.
30 class RegisterNotificationTask : public Task { 30 class RegisterNotificationTask : public Task {
31 public: 31 public:
32 RegisterNotificationTask( 32 RegisterNotificationTask(
33 MachBroker* broker) 33 MachBroker* broker)
34 : broker_(broker) { } 34 : broker_(broker) { }
35 35
36 virtual void Run() { 36 virtual void Run() {
37 broker_->registrar_.Add(broker_, 37 broker_->registrar_.Add(broker_,
38 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 38 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
39 NotificationService::AllBrowserContextsAndSources()); 39 content::NotificationService::AllBrowserContextsAndSources());
40 broker_->registrar_.Add(broker_, 40 broker_->registrar_.Add(broker_,
41 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 41 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
42 NotificationService::AllBrowserContextsAndSources()); 42 content::NotificationService::AllBrowserContextsAndSources());
43 broker_->registrar_.Add(broker_, 43 broker_->registrar_.Add(broker_,
44 content::NOTIFICATION_CHILD_PROCESS_CRASHED, 44 content::NOTIFICATION_CHILD_PROCESS_CRASHED,
45 NotificationService::AllBrowserContextsAndSources()); 45 content::NotificationService::AllBrowserContextsAndSources());
46 broker_->registrar_.Add(broker_, 46 broker_->registrar_.Add(broker_,
47 content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED, 47 content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED,
48 NotificationService::AllBrowserContextsAndSources()); 48 content::NotificationService::AllBrowserContextsAndSources());
49 } 49 }
50 50
51 private: 51 private:
52 MachBroker* broker_; 52 MachBroker* broker_;
53 DISALLOW_COPY_AND_ASSIGN(RegisterNotificationTask); 53 DISALLOW_COPY_AND_ASSIGN(RegisterNotificationTask);
54 }; 54 };
55 55
56 class MachListenerThreadDelegate : public base::PlatformThread::Delegate { 56 class MachListenerThreadDelegate : public base::PlatformThread::Delegate {
57 public: 57 public:
58 MachListenerThreadDelegate(MachBroker* broker) : broker_(broker) { 58 MachListenerThreadDelegate(MachBroker* broker) : broker_(broker) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 // static 225 // static
226 std::string MachBroker::GetMachPortName() { 226 std::string MachBroker::GetMachPortName() {
227 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 227 const CommandLine* command_line = CommandLine::ForCurrentProcess();
228 const bool is_child = command_line->HasSwitch(switches::kProcessType); 228 const bool is_child = command_line->HasSwitch(switches::kProcessType);
229 229
230 // In non-browser (child) processes, use the parent's pid. 230 // In non-browser (child) processes, use the parent's pid.
231 const pid_t pid = is_child ? getppid() : getpid(); 231 const pid_t pid = is_child ? getppid() : getpid();
232 return base::StringPrintf("%s.rohitfork.%d", base::mac::BaseBundleID(), pid); 232 return base::StringPrintf("%s.rohitfork.%d", base::mac::BaseBundleID(), pid);
233 } 233 }
OLDNEW
« no previous file with comments | « content/browser/host_zoom_map.cc ('k') | content/browser/notification_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698