| OLD | NEW |
| 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 "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h" | 5 #include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 ExtensionBluetoothEventRouter::ExtensionBluetoothEventRouter( | 46 ExtensionBluetoothEventRouter::ExtensionBluetoothEventRouter( |
| 47 content::BrowserContext* context) | 47 content::BrowserContext* context) |
| 48 : browser_context_(context), | 48 : browser_context_(context), |
| 49 adapter_(NULL), | 49 adapter_(NULL), |
| 50 num_event_listeners_(0), | 50 num_event_listeners_(0), |
| 51 next_socket_id_(1), | 51 next_socket_id_(1), |
| 52 weak_ptr_factory_(this) { | 52 weak_ptr_factory_(this) { |
| 53 DCHECK(browser_context_); | 53 DCHECK(browser_context_); |
| 54 registrar_.Add(this, | 54 registrar_.Add(this, |
| 55 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 55 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 56 content::Source<content::BrowserContext>(browser_context_)); | 56 content::Source<content::BrowserContext>(browser_context_)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 ExtensionBluetoothEventRouter::~ExtensionBluetoothEventRouter() { | 59 ExtensionBluetoothEventRouter::~ExtensionBluetoothEventRouter() { |
| 60 if (adapter_.get()) { | 60 if (adapter_.get()) { |
| 61 adapter_->RemoveObserver(this); | 61 adapter_->RemoveObserver(this); |
| 62 adapter_ = NULL; | 62 adapter_ = NULL; |
| 63 } | 63 } |
| 64 DLOG_IF(WARNING, socket_map_.size() != 0) | 64 DLOG_IF(WARNING, socket_map_.size() != 0) |
| 65 << "Bluetooth sockets are still open."; | 65 << "Bluetooth sockets are still open."; |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 delete iter->second; | 402 delete iter->second; |
| 403 discovery_session_map_[extension_id] = discovery_session.release(); | 403 discovery_session_map_[extension_id] = discovery_session.release(); |
| 404 callback.Run(); | 404 callback.Run(); |
| 405 } | 405 } |
| 406 | 406 |
| 407 void ExtensionBluetoothEventRouter::Observe( | 407 void ExtensionBluetoothEventRouter::Observe( |
| 408 int type, | 408 int type, |
| 409 const content::NotificationSource& source, | 409 const content::NotificationSource& source, |
| 410 const content::NotificationDetails& details) { | 410 const content::NotificationDetails& details) { |
| 411 switch (type) { | 411 switch (type) { |
| 412 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 412 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
| 413 extensions::UnloadedExtensionInfo* info = | 413 extensions::UnloadedExtensionInfo* info = |
| 414 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); | 414 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); |
| 415 CleanUpForExtension(info->extension->id()); | 415 CleanUpForExtension(info->extension->id()); |
| 416 break; | 416 break; |
| 417 } | 417 } |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 | 420 |
| 421 } // namespace extensions | 421 } // namespace extensions |
| OLD | NEW |