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

Side by Side Diff: content/child/bluetooth/bluetooth_dispatcher.cc

Issue 1058123002: Refactor BluetoothDispatcher to use CurrentWorkerId everywhere. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/child/bluetooth/bluetooth_dispatcher.h" 5 #include "content/child/bluetooth/bluetooth_dispatcher.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 BluetoothDispatcher* BluetoothDispatcher::GetOrCreateThreadSpecificInstance( 73 BluetoothDispatcher* BluetoothDispatcher::GetOrCreateThreadSpecificInstance(
74 ThreadSafeSender* thread_safe_sender) { 74 ThreadSafeSender* thread_safe_sender) {
75 if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) { 75 if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) {
76 NOTREACHED() << "Re-instantiating TLS BluetoothDispatcher."; 76 NOTREACHED() << "Re-instantiating TLS BluetoothDispatcher.";
77 g_dispatcher_tls.Pointer()->Set(NULL); 77 g_dispatcher_tls.Pointer()->Set(NULL);
78 } 78 }
79 if (g_dispatcher_tls.Pointer()->Get()) 79 if (g_dispatcher_tls.Pointer()->Get())
80 return g_dispatcher_tls.Pointer()->Get(); 80 return g_dispatcher_tls.Pointer()->Get();
81 81
82 BluetoothDispatcher* dispatcher = new BluetoothDispatcher(thread_safe_sender); 82 BluetoothDispatcher* dispatcher = new BluetoothDispatcher(thread_safe_sender);
83 if (WorkerTaskRunner::Instance()->CurrentWorkerId()) 83 if (CurrentWorkerId())
84 WorkerTaskRunner::Instance()->AddStopObserver(dispatcher); 84 WorkerTaskRunner::Instance()->AddStopObserver(dispatcher);
85 return dispatcher; 85 return dispatcher;
86 } 86 }
87 87
88 bool BluetoothDispatcher::Send(IPC::Message* msg) { 88 bool BluetoothDispatcher::Send(IPC::Message* msg) {
89 return thread_safe_sender_->Send(msg); 89 return thread_safe_sender_->Send(msg);
90 } 90 }
91 91
92 void BluetoothDispatcher::OnMessageReceived(const IPC::Message& msg) { 92 void BluetoothDispatcher::OnMessageReceived(const IPC::Message& msg) {
93 bool handled = true; 93 bool handled = true;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 int request_id, 138 int request_id,
139 BluetoothError error_type) { 139 BluetoothError error_type) {
140 DCHECK(pending_requests_.Lookup(request_id)) << request_id; 140 DCHECK(pending_requests_.Lookup(request_id)) << request_id;
141 pending_requests_.Lookup(request_id) 141 pending_requests_.Lookup(request_id)
142 ->onError(new WebBluetoothError( 142 ->onError(new WebBluetoothError(
143 WebBluetoothErrorFromBluetoothError(error_type), "")); 143 WebBluetoothErrorFromBluetoothError(error_type), ""));
144 pending_requests_.Remove(request_id); 144 pending_requests_.Remove(request_id);
145 } 145 }
146 146
147 } // namespace content 147 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698