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

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

Issue 1566573002: Fix race on mojo message pump shutdown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-waitset-message-pump
Patch Set: Revert stuff. Created 4 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
« no previous file with comments | « base/threading/thread_restrictions.h ('k') | mojo/message_pump/message_pump_mojo.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 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/message_pump/handle_watcher.h" 5 #include "mojo/message_pump/handle_watcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 268
269 void WatcherThreadManager::AddRequest(const RequestData& data) { 269 void WatcherThreadManager::AddRequest(const RequestData& data) {
270 { 270 {
271 base::AutoLock auto_lock(lock_); 271 base::AutoLock auto_lock(lock_);
272 const bool was_empty = requests_.empty(); 272 const bool was_empty = requests_.empty();
273 requests_.push_back(data); 273 requests_.push_back(data);
274 if (!was_empty) 274 if (!was_empty)
275 return; 275 return;
276 } 276 }
277 277
278 // With the new Mojo EDK, the MojoMessagePump will destruct when it sees that
279 // the IO thread has gone away. So at shutdown this can be null.
280 if (!thread_.task_runner())
281 return;
282
283 // We outlive |thread_|, so it's safe to use Unretained() here. 278 // We outlive |thread_|, so it's safe to use Unretained() here.
284 thread_.task_runner()->PostTask( 279 thread_.task_runner()->PostTask(
285 FROM_HERE, 280 FROM_HERE,
286 base::Bind(&WatcherThreadManager::ProcessRequestsOnBackendThread, 281 base::Bind(&WatcherThreadManager::ProcessRequestsOnBackendThread,
287 base::Unretained(this))); 282 base::Unretained(this)));
288 } 283 }
289 284
290 void WatcherThreadManager::ProcessRequestsOnBackendThread() { 285 void WatcherThreadManager::ProcessRequestsOnBackendThread() {
291 DCHECK_EQ(thread_.message_loop(), base::MessageLoop::current()); 286 DCHECK_EQ(thread_.message_loop(), base::MessageLoop::current());
292 287
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 this, handle, handle_signals, deadline, callback)); 477 this, handle, handle_signals, deadline, callback));
483 } 478 }
484 } 479 }
485 480
486 void HandleWatcher::Stop() { 481 void HandleWatcher::Stop() {
487 state_.reset(); 482 state_.reset();
488 } 483 }
489 484
490 } // namespace common 485 } // namespace common
491 } // namespace mojo 486 } // namespace mojo
OLDNEW
« no previous file with comments | « base/threading/thread_restrictions.h ('k') | mojo/message_pump/message_pump_mojo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698