| OLD | NEW |
| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 270 } |
| 271 | 271 |
| 272 // We outlive |thread_|, so it's safe to use Unretained() here. | 272 // We outlive |thread_|, so it's safe to use Unretained() here. |
| 273 thread_.task_runner()->PostTask( | 273 thread_.task_runner()->PostTask( |
| 274 FROM_HERE, | 274 FROM_HERE, |
| 275 base::Bind(&WatcherThreadManager::ProcessRequestsOnBackendThread, | 275 base::Bind(&WatcherThreadManager::ProcessRequestsOnBackendThread, |
| 276 base::Unretained(this))); | 276 base::Unretained(this))); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void WatcherThreadManager::ProcessRequestsOnBackendThread() { | 279 void WatcherThreadManager::ProcessRequestsOnBackendThread() { |
| 280 DCHECK_EQ(thread_.message_loop(), base::MessageLoop::current()); | 280 DCHECK(thread_.task_runner()->BelongsToCurrentThread()); |
| 281 | 281 |
| 282 Requests requests; | 282 Requests requests; |
| 283 { | 283 { |
| 284 base::AutoLock auto_lock(lock_); | 284 base::AutoLock auto_lock(lock_); |
| 285 requests_.swap(requests); | 285 requests_.swap(requests); |
| 286 } | 286 } |
| 287 for (size_t i = 0; i < requests.size(); ++i) { | 287 for (size_t i = 0; i < requests.size(); ++i) { |
| 288 if (requests[i].type == REQUEST_START) { | 288 if (requests[i].type == REQUEST_START) { |
| 289 backend_.StartWatching(requests[i].start_data); | 289 backend_.StartWatching(requests[i].start_data); |
| 290 } else { | 290 } else { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 this, handle, handle_signals, deadline, callback)); | 471 this, handle, handle_signals, deadline, callback)); |
| 472 } | 472 } |
| 473 } | 473 } |
| 474 | 474 |
| 475 void HandleWatcher::Stop() { | 475 void HandleWatcher::Stop() { |
| 476 state_.reset(); | 476 state_.reset(); |
| 477 } | 477 } |
| 478 | 478 |
| 479 } // namespace common | 479 } // namespace common |
| 480 } // namespace mojo | 480 } // namespace mojo |
| OLD | NEW |