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

Side by Side Diff: chrome/common/service_process_util_win.cc

Issue 5971008: move base/object_watcher into base/win and add the win namespace. Fixup calle... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 | « chrome/common/process_watcher_win.cc ('k') | chrome/service/cloud_print/print_system_win.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/common/service_process_util.h" 5 #include "chrome/common/service_process_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/object_watcher.h"
11 #include "base/path_service.h" 10 #include "base/path_service.h"
12 #include "base/scoped_handle_win.h" 11 #include "base/scoped_handle_win.h"
13 #include "base/string16.h" 12 #include "base/string16.h"
14 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "base/win/object_watcher.h"
15 #include "base/win/win_util.h" 15 #include "base/win/win_util.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 17
18 namespace { 18 namespace {
19 19
20 string16 GetServiceProcessReadyEventName() { 20 string16 GetServiceProcessReadyEventName() {
21 return UTF8ToWide( 21 return UTF8ToWide(
22 GetServiceProcessScopedVersionedName("_service_ready")); 22 GetServiceProcessScopedVersionedName("_service_ready"));
23 } 23 }
24 24
25 string16 GetServiceProcessShutdownEventName() { 25 string16 GetServiceProcessShutdownEventName() {
26 return UTF8ToWide( 26 return UTF8ToWide(
27 GetServiceProcessScopedVersionedName("_service_shutdown_evt")); 27 GetServiceProcessScopedVersionedName("_service_shutdown_evt"));
28 } 28 }
29 29
30 class ServiceProcessShutdownMonitor : public base::ObjectWatcher::Delegate { 30 class ServiceProcessShutdownMonitor
31 : public base::win::ObjectWatcher::Delegate {
31 public: 32 public:
32 explicit ServiceProcessShutdownMonitor(Task* shutdown_task) 33 explicit ServiceProcessShutdownMonitor(Task* shutdown_task)
33 : shutdown_task_(shutdown_task) { 34 : shutdown_task_(shutdown_task) {
34 } 35 }
35 void Start() { 36 void Start() {
36 string16 event_name = GetServiceProcessShutdownEventName(); 37 string16 event_name = GetServiceProcessShutdownEventName();
37 CHECK(event_name.length() <= MAX_PATH); 38 CHECK(event_name.length() <= MAX_PATH);
38 shutdown_event_.Set(CreateEvent(NULL, TRUE, FALSE, event_name.c_str())); 39 shutdown_event_.Set(CreateEvent(NULL, TRUE, FALSE, event_name.c_str()));
39 watcher_.StartWatching(shutdown_event_.Get(), this); 40 watcher_.StartWatching(shutdown_event_.Get(), this);
40 } 41 }
41 42
42 // base::ObjectWatcher::Delegate implementation. 43 // base::ObjectWatcher::Delegate implementation.
43 virtual void OnObjectSignaled(HANDLE object) { 44 virtual void OnObjectSignaled(HANDLE object) {
44 shutdown_task_->Run(); 45 shutdown_task_->Run();
45 shutdown_task_.reset(); 46 shutdown_task_.reset();
46 } 47 }
47 48
48 private: 49 private:
49 ScopedHandle shutdown_event_; 50 ScopedHandle shutdown_event_;
50 base::ObjectWatcher watcher_; 51 base::win::ObjectWatcher watcher_;
51 scoped_ptr<Task> shutdown_task_; 52 scoped_ptr<Task> shutdown_task_;
52 }; 53 };
53 54
54 } // namespace 55 } // namespace
55 56
56 bool ForceServiceProcessShutdown(const std::string& version) { 57 bool ForceServiceProcessShutdown(const std::string& version) {
57 ScopedHandle shutdown_event; 58 ScopedHandle shutdown_event;
58 std::string versioned_name = version; 59 std::string versioned_name = version;
59 versioned_name.append("_service_shutdown_evt"); 60 versioned_name.append("_service_shutdown_evt");
60 string16 event_name = 61 string16 event_name =
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 137 }
137 138
138 void ServiceProcessState::TearDownState() { 139 void ServiceProcessState::TearDownState() {
139 delete state_; 140 delete state_;
140 state_ = NULL; 141 state_ = NULL;
141 } 142 }
142 143
143 bool ServiceProcessState::ShouldHandleOtherVersion() { 144 bool ServiceProcessState::ShouldHandleOtherVersion() {
144 return true; 145 return true;
145 } 146 }
OLDNEW
« no previous file with comments | « chrome/common/process_watcher_win.cc ('k') | chrome/service/cloud_print/print_system_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698