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

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: Created 4 years, 12 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 base::Bind(&BluetoothEventRouter::AddPairingDelegateImpl, 233 base::Bind(&BluetoothEventRouter::AddPairingDelegateImpl,
234 weak_ptr_factory_.GetWeakPtr(), extension_id))); 234 weak_ptr_factory_.GetWeakPtr(), extension_id)));
235 return; 235 return;
236 } 236 }
237 AddPairingDelegateImpl(extension_id); 237 AddPairingDelegateImpl(extension_id);
238 } 238 }
239 239
240 void BluetoothEventRouter::AddPairingDelegateImpl( 240 void BluetoothEventRouter::AddPairingDelegateImpl(
241 const std::string& extension_id) { 241 const std::string& extension_id) {
242 if (!adapter_.get()) { 242 if (!adapter_.get()) {
243 LOG(ERROR) << "Unable to get adatper."; 243 LOG(ERROR) << "Unable to get adatper for extension_id: " << extension_id;
michaelpg 2015/12/22 00:49:48 adapter
stevenjb 2015/12/28 18:22:11 Done.
244 return; 244 return;
245 } 245 }
246 if (!ContainsKey(pairing_delegate_map_, extension_id)) { 246 if (ContainsKey(pairing_delegate_map_, extension_id)) {
247 BluetoothApiPairingDelegate* delegate = 247 // For WebUI there may be more than one page open to the same url
248 new BluetoothApiPairingDelegate(browser_context_); 248 // (e.g. chrome://settings). These will share the same pairing delegate.
249 DCHECK(adapter_.get()); 249 VLOG(1) << "Pairing delegate already exists for extension_id: "
250 adapter_->AddPairingDelegate( 250 << extension_id;
251 delegate, device::BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); 251 return;
252 pairing_delegate_map_[extension_id] = delegate;
253 } else {
254 LOG(ERROR) << "Pairing delegate already exists for extension. "
255 << "There should be at most one onPairing listener.";
256 NOTREACHED();
257 } 252 }
253 BluetoothApiPairingDelegate* delegate =
254 new BluetoothApiPairingDelegate(browser_context_);
255 DCHECK(adapter_.get());
256 adapter_->AddPairingDelegate(
257 delegate, device::BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH);
258 pairing_delegate_map_[extension_id] = delegate;
258 } 259 }
259 260
260 void BluetoothEventRouter::RemovePairingDelegate( 261 void BluetoothEventRouter::RemovePairingDelegate(
261 const std::string& extension_id) { 262 const std::string& extension_id) {
262 if (ContainsKey(pairing_delegate_map_, extension_id)) { 263 if (ContainsKey(pairing_delegate_map_, extension_id)) {
263 BluetoothApiPairingDelegate* delegate = pairing_delegate_map_[extension_id]; 264 BluetoothApiPairingDelegate* delegate = pairing_delegate_map_[extension_id];
264 if (adapter_.get()) 265 if (adapter_.get())
265 adapter_->RemovePairingDelegate(delegate); 266 adapter_->RemovePairingDelegate(delegate);
266 pairing_delegate_map_.erase(extension_id); 267 pairing_delegate_map_.erase(extension_id);
267 delete delegate; 268 delete delegate;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 469 }
469 470
470 void BluetoothEventRouter::OnExtensionUnloaded( 471 void BluetoothEventRouter::OnExtensionUnloaded(
471 content::BrowserContext* browser_context, 472 content::BrowserContext* browser_context,
472 const Extension* extension, 473 const Extension* extension,
473 UnloadedExtensionInfo::Reason reason) { 474 UnloadedExtensionInfo::Reason reason) {
474 CleanUpForExtension(extension->id()); 475 CleanUpForExtension(extension->id());
475 } 476 }
476 477
477 } // namespace extensions 478 } // 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