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

Side by Side Diff: mojo/common/handle_watcher.cc

Issue 457933002: Replace Chrome IPC with Mojo IPC for querying BatteryStatus service Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 3 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 | « device/device_tests.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/common/handle_watcher.h" 5 #include "mojo/common/handle_watcher.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 void WatcherBackend::RemoveAndNotify(const Handle& handle, 118 void WatcherBackend::RemoveAndNotify(const Handle& handle,
119 MojoResult result) { 119 MojoResult result) {
120 if (handle_to_data_.count(handle) == 0) 120 if (handle_to_data_.count(handle) == 0)
121 return; 121 return;
122 122
123 const WatchData data(handle_to_data_[handle]); 123 const WatchData data(handle_to_data_[handle]);
124 handle_to_data_.erase(handle); 124 handle_to_data_.erase(handle);
125 MessagePumpMojo::current()->RemoveHandler(handle); 125 MessagePumpMojo::current()->RemoveHandler(handle);
126
126 data.message_loop->PostTask(FROM_HERE, base::Bind(data.callback, result)); 127 data.message_loop->PostTask(FROM_HERE, base::Bind(data.callback, result));
127 } 128 }
128 129
129 bool WatcherBackend::GetMojoHandleByWatcherID(WatcherID watcher_id, 130 bool WatcherBackend::GetMojoHandleByWatcherID(WatcherID watcher_id,
130 Handle* handle) const { 131 Handle* handle) const {
131 for (HandleToWatchDataMap::const_iterator i = handle_to_data_.begin(); 132 for (HandleToWatchDataMap::const_iterator i = handle_to_data_.begin();
132 i != handle_to_data_.end(); ++i) { 133 i != handle_to_data_.end(); ++i) {
133 if (i->second.id == watcher_id) { 134 if (i->second.id == watcher_id) {
134 *handle = i->second.handle; 135 *handle = i->second.handle;
135 return true; 136 return true;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 this, handle, handle_signals, deadline, callback)); 467 this, handle, handle_signals, deadline, callback));
467 } 468 }
468 } 469 }
469 470
470 void HandleWatcher::Stop() { 471 void HandleWatcher::Stop() {
471 state_.reset(); 472 state_.reset();
472 } 473 }
473 474
474 } // namespace common 475 } // namespace common
475 } // namespace mojo 476 } // namespace mojo
OLDNEW
« no previous file with comments | « device/device_tests.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698