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

Side by Side Diff: base/object_watcher.cc

Issue 8001: Make IPC::SyncChannel not duplicate the underlying MessageLoop implementation... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 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 | « base/object_watcher.h ('k') | base/object_watcher_unittest.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/object_watcher.h" 5 #include "base/object_watcher.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace base { 9 namespace base {
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // need to take care to delete it here. 100 // need to take care to delete it here.
101 if (!watch_->did_signal) 101 if (!watch_->did_signal)
102 delete watch_; 102 delete watch_;
103 103
104 watch_ = NULL; 104 watch_ = NULL;
105 105
106 MessageLoop::current()->RemoveDestructionObserver(this); 106 MessageLoop::current()->RemoveDestructionObserver(this);
107 return true; 107 return true;
108 } 108 }
109 109
110 HANDLE ObjectWatcher::GetWatchedObject() {
111 if (!watch_)
112 return NULL;
113
114 return watch_->object;
115 }
116
110 // static 117 // static
111 void CALLBACK ObjectWatcher::DoneWaiting(void* param, BOOLEAN timed_out) { 118 void CALLBACK ObjectWatcher::DoneWaiting(void* param, BOOLEAN timed_out) {
112 DCHECK(!timed_out); 119 DCHECK(!timed_out);
113 120
114 Watch* watch = static_cast<Watch*>(param); 121 Watch* watch = static_cast<Watch*>(param);
115 122
116 // Record that we ran this function. 123 // Record that we ran this function.
117 watch->did_signal = true; 124 watch->did_signal = true;
118 125
119 // We rely on the locking in PostTask() to ensure that a memory barrier is 126 // We rely on the locking in PostTask() to ensure that a memory barrier is
120 // provided, which in turn ensures our change to did_signal can be observed 127 // provided, which in turn ensures our change to did_signal can be observed
121 // on the target thread. 128 // on the target thread.
122 watch->origin_loop->PostTask(FROM_HERE, watch); 129 watch->origin_loop->PostTask(FROM_HERE, watch);
123 } 130 }
124 131
125 void ObjectWatcher::WillDestroyCurrentMessageLoop() { 132 void ObjectWatcher::WillDestroyCurrentMessageLoop() {
126 // Need to shutdown the watch so that we don't try to access the MessageLoop 133 // Need to shutdown the watch so that we don't try to access the MessageLoop
127 // after this point. 134 // after this point.
128 StopWatching(); 135 StopWatching();
129 } 136 }
130 137
131 } // namespace base 138 } // namespace base
132 139
OLDNEW
« no previous file with comments | « base/object_watcher.h ('k') | base/object_watcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698