OLD | NEW |
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 "ipc/mojo/scoped_ipc_support.h" | 5 #include "ipc/mojo/scoped_ipc_support.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // IO thread. | 78 // IO thread. |
79 MessageLoopObserver* observer_; | 79 MessageLoopObserver* observer_; |
80 | 80 |
81 scoped_refptr<base::TaskRunner> io_thread_task_runner_; | 81 scoped_refptr<base::TaskRunner> io_thread_task_runner_; |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(IPCSupportInitializer); | 83 DISALLOW_COPY_AND_ASSIGN(IPCSupportInitializer); |
84 }; | 84 }; |
85 | 85 |
86 void IPCSupportInitializer::Init( | 86 void IPCSupportInitializer::Init( |
87 scoped_refptr<base::TaskRunner> io_thread_task_runner) { | 87 scoped_refptr<base::TaskRunner> io_thread_task_runner) { |
| 88 CHECK(io_thread_task_runner); |
88 base::AutoLock locker(lock_); | 89 base::AutoLock locker(lock_); |
89 DCHECK((init_count_ == 0 && !io_thread_task_runner_) || | 90 DCHECK((init_count_ == 0 && !io_thread_task_runner_) || |
90 io_thread_task_runner_ == io_thread_task_runner); | 91 io_thread_task_runner_ == io_thread_task_runner); |
91 | 92 |
92 if (shutting_down_) { | 93 if (shutting_down_) { |
93 // If reinitialized before a pending shutdown task is executed, we | 94 // If reinitialized before a pending shutdown task is executed, we |
94 // effectively cancel the shutdown task. | 95 // effectively cancel the shutdown task. |
95 DCHECK(init_count_ == 1); | 96 DCHECK(init_count_ == 1); |
96 shutting_down_ = false; | 97 shutting_down_ = false; |
97 return; | 98 return; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 ScopedIPCSupport::ScopedIPCSupport( | 159 ScopedIPCSupport::ScopedIPCSupport( |
159 scoped_refptr<base::TaskRunner> io_thread_task_runner) { | 160 scoped_refptr<base::TaskRunner> io_thread_task_runner) { |
160 ipc_support_initializer.Get().Init(io_thread_task_runner); | 161 ipc_support_initializer.Get().Init(io_thread_task_runner); |
161 } | 162 } |
162 | 163 |
163 ScopedIPCSupport::~ScopedIPCSupport() { | 164 ScopedIPCSupport::~ScopedIPCSupport() { |
164 ipc_support_initializer.Get().ShutDown(false); | 165 ipc_support_initializer.Get().ShutDown(false); |
165 } | 166 } |
166 | 167 |
167 } // namespace IPC | 168 } // namespace IPC |
OLD | NEW |