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

Side by Side Diff: extensions/browser/api/bluetooth/bluetooth_event_router.cc

Issue 1540323002: Replace NOTREACHED with VLOG in BluetoothEventRouter::AddPairingDelegateImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Typo 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 | « 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "extensions/browser/api/bluetooth/bluetooth_event_router.h" 5 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 base::Bind(&BluetoothEventRouter::AddPairingDelegateImpl, 234 base::Bind(&BluetoothEventRouter::AddPairingDelegateImpl,
235 weak_ptr_factory_.GetWeakPtr(), extension_id))); 235 weak_ptr_factory_.GetWeakPtr(), extension_id)));
236 return; 236 return;
237 } 237 }
238 AddPairingDelegateImpl(extension_id); 238 AddPairingDelegateImpl(extension_id);
239 } 239 }
240 240
241 void BluetoothEventRouter::AddPairingDelegateImpl( 241 void BluetoothEventRouter::AddPairingDelegateImpl(
242 const std::string& extension_id) { 242 const std::string& extension_id) {
243 if (!adapter_.get()) { 243 if (!adapter_.get()) {
244 LOG(ERROR) << "Unable to get adatper."; 244 LOG(ERROR) << "Unable to get adapter for extension_id: " << extension_id;
245 return; 245 return;
246 } 246 }
247 if (!ContainsKey(pairing_delegate_map_, extension_id)) { 247 if (ContainsKey(pairing_delegate_map_, extension_id)) {
248 BluetoothApiPairingDelegate* delegate = 248 // For WebUI there may be more than one page open to the same url
249 new BluetoothApiPairingDelegate(browser_context_); 249 // (e.g. chrome://settings). These will share the same pairing delegate.
250 DCHECK(adapter_.get()); 250 VLOG(1) << "Pairing delegate already exists for extension_id: "
251 adapter_->AddPairingDelegate( 251 << extension_id;
252 delegate, device::BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); 252 return;
253 pairing_delegate_map_[extension_id] = delegate;
254 } else {
255 LOG(ERROR) << "Pairing delegate already exists for extension. "
256 << "There should be at most one onPairing listener.";
257 NOTREACHED();
258 } 253 }
254 BluetoothApiPairingDelegate* delegate =
255 new BluetoothApiPairingDelegate(browser_context_);
256 DCHECK(adapter_.get());
257 adapter_->AddPairingDelegate(
258 delegate, device::BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH);
259 pairing_delegate_map_[extension_id] = delegate;
259 } 260 }
260 261
261 void BluetoothEventRouter::RemovePairingDelegate( 262 void BluetoothEventRouter::RemovePairingDelegate(
262 const std::string& extension_id) { 263 const std::string& extension_id) {
263 if (ContainsKey(pairing_delegate_map_, extension_id)) { 264 if (ContainsKey(pairing_delegate_map_, extension_id)) {
264 BluetoothApiPairingDelegate* delegate = pairing_delegate_map_[extension_id]; 265 BluetoothApiPairingDelegate* delegate = pairing_delegate_map_[extension_id];
265 if (adapter_.get()) 266 if (adapter_.get())
266 adapter_->RemovePairingDelegate(delegate); 267 adapter_->RemovePairingDelegate(delegate);
267 pairing_delegate_map_.erase(extension_id); 268 pairing_delegate_map_.erase(extension_id);
268 delete delegate; 269 delete delegate;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 470 }
470 471
471 void BluetoothEventRouter::OnExtensionUnloaded( 472 void BluetoothEventRouter::OnExtensionUnloaded(
472 content::BrowserContext* browser_context, 473 content::BrowserContext* browser_context,
473 const Extension* extension, 474 const Extension* extension,
474 UnloadedExtensionInfo::Reason reason) { 475 UnloadedExtensionInfo::Reason reason) {
475 CleanUpForExtension(extension->id()); 476 CleanUpForExtension(extension->id());
476 } 477 }
477 478
478 } // namespace extensions 479 } // namespace extensions
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