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

Side by Side Diff: mojo/public/cpp/system/watcher.cc

Issue 1895083004: [Draft] See what tests are broken. Base URL: https://chromium.googlesource.com/chromium/src.git@27_watcher_no_abort
Patch Set: Created 4 years, 7 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
« no previous file with comments | « mojo/public/cpp/system/tests/watcher_unittest.cc ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/public/cpp/system/watcher.h" 5 #include "mojo/public/cpp/system/watcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return handle_.is_valid(); 65 return handle_.is_valid();
66 } 66 }
67 67
68 MojoResult Watcher::Start(Handle handle, 68 MojoResult Watcher::Start(Handle handle,
69 MojoHandleSignals signals, 69 MojoHandleSignals signals,
70 const ReadyCallback& callback) { 70 const ReadyCallback& callback) {
71 DCHECK(thread_checker_.CalledOnValidThread()); 71 DCHECK(thread_checker_.CalledOnValidThread());
72 DCHECK(!IsWatching()); 72 DCHECK(!IsWatching());
73 DCHECK(!callback.is_null()); 73 DCHECK(!callback.is_null());
74 74
75 message_loop_observer_.reset(new MessageLoopObserver(this)); 75 // message_loop_observer_.reset(new MessageLoopObserver(this));
76 callback_ = callback; 76 callback_ = callback;
77 handle_ = handle; 77 handle_ = handle;
78 MojoResult result = MojoWatch(handle_.value(), signals, 78 MojoResult result = MojoWatch(handle_.value(), signals,
79 &Watcher::CallOnHandleReady, 79 &Watcher::CallOnHandleReady,
80 reinterpret_cast<uintptr_t>(this)); 80 reinterpret_cast<uintptr_t>(this));
81 if (result != MOJO_RESULT_OK) { 81 if (result != MOJO_RESULT_OK) {
82 handle_.set_value(kInvalidHandleValue); 82 handle_.set_value(kInvalidHandleValue);
83 callback_.Reset(); 83 callback_.Reset();
84 message_loop_observer_.reset(); 84 message_loop_observer_.reset();
85 DCHECK(result == MOJO_RESULT_FAILED_PRECONDITION || 85 DCHECK(result == MOJO_RESULT_FAILED_PRECONDITION ||
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // default task runner for the IO thread. 141 // default task runner for the IO thread.
142 watcher->OnHandleReady(result); 142 watcher->OnHandleReady(result);
143 } else { 143 } else {
144 watcher->task_runner_->PostTask( 144 watcher->task_runner_->PostTask(
145 FROM_HERE, 145 FROM_HERE,
146 base::Bind(&Watcher::OnHandleReady, watcher->weak_self_, result)); 146 base::Bind(&Watcher::OnHandleReady, watcher->weak_self_, result));
147 } 147 }
148 } 148 }
149 149
150 } // namespace mojo 150 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/system/tests/watcher_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698