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

Side by Side Diff: third_party/mojo/src/mojo/edk/system/slave_connection_manager.cc

Issue 954643002: Update mojo sdk to rev 3d23dae011859a2aae49f1d1adde705c8e85d819 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resolve more msvc linkage woes Created 5 years, 9 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/edk/system/slave_connection_manager.h" 5 #include "mojo/edk/system/slave_connection_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 30 matching lines...) Expand all
41 embedder::SlaveProcessDelegate* slave_process_delegate, 41 embedder::SlaveProcessDelegate* slave_process_delegate,
42 embedder::ScopedPlatformHandle platform_handle) { 42 embedder::ScopedPlatformHandle platform_handle) {
43 DCHECK(delegate_thread_task_runner); 43 DCHECK(delegate_thread_task_runner);
44 DCHECK(slave_process_delegate); 44 DCHECK(slave_process_delegate);
45 DCHECK(platform_handle.is_valid()); 45 DCHECK(platform_handle.is_valid());
46 DCHECK(!delegate_thread_task_runner_); 46 DCHECK(!delegate_thread_task_runner_);
47 DCHECK(!slave_process_delegate_); 47 DCHECK(!slave_process_delegate_);
48 DCHECK(!private_thread_.message_loop()); 48 DCHECK(!private_thread_.message_loop());
49 49
50 delegate_thread_task_runner_ = delegate_thread_task_runner; 50 delegate_thread_task_runner_ = delegate_thread_task_runner;
51 AssertOnDelegateThread();
52 slave_process_delegate_ = slave_process_delegate; 51 slave_process_delegate_ = slave_process_delegate;
53 CHECK(private_thread_.StartWithOptions( 52 CHECK(private_thread_.StartWithOptions(
54 base::Thread::Options(base::MessageLoop::TYPE_IO, 0))); 53 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)));
55 private_thread_.message_loop()->PostTask( 54 private_thread_.message_loop()->PostTask(
56 FROM_HERE, 55 FROM_HERE,
57 base::Bind(&SlaveConnectionManager::InitOnPrivateThread, 56 base::Bind(&SlaveConnectionManager::InitOnPrivateThread,
58 base::Unretained(this), base::Passed(&platform_handle))); 57 base::Unretained(this), base::Passed(&platform_handle)));
59 event_.Wait(); 58 event_.Wait();
60 } 59 }
61 60
62 void SlaveConnectionManager::Shutdown() { 61 void SlaveConnectionManager::Shutdown() {
63 AssertOnDelegateThread(); 62 AssertNotOnPrivateThread();
64 DCHECK(slave_process_delegate_); 63 DCHECK(slave_process_delegate_);
65 DCHECK(private_thread_.message_loop()); 64 DCHECK(private_thread_.message_loop());
66 65
67 // The |Stop()| will actually finish all posted tasks. 66 // The |Stop()| will actually finish all posted tasks.
68 private_thread_.message_loop()->PostTask( 67 private_thread_.message_loop()->PostTask(
69 FROM_HERE, base::Bind(&SlaveConnectionManager::ShutdownOnPrivateThread, 68 FROM_HERE, base::Bind(&SlaveConnectionManager::ShutdownOnPrivateThread,
70 base::Unretained(this))); 69 base::Unretained(this)));
71 private_thread_.Stop(); 70 private_thread_.Stop();
72 slave_process_delegate_ = nullptr; 71 slave_process_delegate_ = nullptr;
73 delegate_thread_task_runner_ = nullptr; 72 delegate_thread_task_runner_ = nullptr;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 286
288 raw_channel_->Shutdown(); 287 raw_channel_->Shutdown();
289 raw_channel_.reset(); 288 raw_channel_.reset();
290 289
291 DCHECK(slave_process_delegate_); 290 DCHECK(slave_process_delegate_);
292 delegate_thread_task_runner_->PostTask( 291 delegate_thread_task_runner_->PostTask(
293 FROM_HERE, base::Bind(&embedder::SlaveProcessDelegate::OnMasterDisconnect, 292 FROM_HERE, base::Bind(&embedder::SlaveProcessDelegate::OnMasterDisconnect,
294 base::Unretained(slave_process_delegate_))); 293 base::Unretained(slave_process_delegate_)));
295 } 294 }
296 295
297 void SlaveConnectionManager::AssertOnDelegateThread() const {
298 DCHECK(base::MessageLoop::current());
299 DCHECK_EQ(base::MessageLoop::current()->task_runner(),
300 delegate_thread_task_runner_);
301 }
302
303 void SlaveConnectionManager::AssertNotOnPrivateThread() const { 296 void SlaveConnectionManager::AssertNotOnPrivateThread() const {
304 // This should only be called after |Init()| and before |Shutdown()|. (If not, 297 // This should only be called after |Init()| and before |Shutdown()|. (If not,
305 // the subsequent |DCHECK_NE()| is invalid, since the current thread may not 298 // the subsequent |DCHECK_NE()| is invalid, since the current thread may not
306 // have a message loop.) 299 // have a message loop.)
307 DCHECK(private_thread_.message_loop()); 300 DCHECK(private_thread_.message_loop());
308 DCHECK_NE(base::MessageLoop::current(), private_thread_.message_loop()); 301 DCHECK_NE(base::MessageLoop::current(), private_thread_.message_loop());
309 } 302 }
310 303
311 void SlaveConnectionManager::AssertOnPrivateThread() const { 304 void SlaveConnectionManager::AssertOnPrivateThread() const {
312 // This should only be called after |Init()| and before |Shutdown()|. 305 // This should only be called after |Init()| and before |Shutdown()|.
313 DCHECK(private_thread_.message_loop()); 306 DCHECK(private_thread_.message_loop());
314 DCHECK_EQ(base::MessageLoop::current(), private_thread_.message_loop()); 307 DCHECK_EQ(base::MessageLoop::current(), private_thread_.message_loop());
315 } 308 }
316 309
317 } // namespace system 310 } // namespace system
318 } // namespace mojo 311 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698