| 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/media_transfer_protocol/media_transfer_protocol_manager
.h" | 5 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "chrome/browser/media_transfer_protocol/media_transfer_protocol_daemon_
client.h" | |
| 18 #include "chrome/browser/media_transfer_protocol/mtp_file_entry.pb.h" | |
| 19 #include "chrome/browser/media_transfer_protocol/mtp_storage_info.pb.h" | |
| 20 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 21 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "device/media_transfer_protocol/media_transfer_protocol_daemon_client.h
" |
| 20 #include "device/media_transfer_protocol/mtp_file_entry.pb.h" |
| 21 #include "device/media_transfer_protocol/mtp_storage_info.pb.h" |
| 22 | 22 |
| 23 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
| 24 #include "chromeos/dbus/dbus_thread_manager.h" | 24 #include "chromeos/dbus/dbus_thread_manager.h" |
| 25 #else | 25 #else |
| 26 #include "dbus/bus.h" | 26 #include "dbus/bus.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 using content::BrowserThread; | 29 using content::BrowserThread; |
| 30 | 30 |
| 31 namespace chrome { | 31 namespace device { |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 MediaTransferProtocolManager* g_media_transfer_protocol_manager = NULL; | 35 MediaTransferProtocolManager* g_media_transfer_protocol_manager = NULL; |
| 36 | 36 |
| 37 // The MediaTransferProtocolManager implementation. | 37 // The MediaTransferProtocolManager implementation. |
| 38 class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager { | 38 class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager { |
| 39 public: | 39 public: |
| 40 MediaTransferProtocolManagerImpl() : weak_ptr_factory_(this) { | 40 MediaTransferProtocolManagerImpl() : weak_ptr_factory_(this) { |
| 41 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) | 41 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 get_file_info_callbacks_.front().Run(entry, false); | 384 get_file_info_callbacks_.front().Run(entry, false); |
| 385 get_file_info_callbacks_.pop(); | 385 get_file_info_callbacks_.pop(); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void OnGetFileInfoError() { | 388 void OnGetFileInfoError() { |
| 389 get_file_info_callbacks_.front().Run(MtpFileEntry(), true); | 389 get_file_info_callbacks_.front().Run(MtpFileEntry(), true); |
| 390 get_file_info_callbacks_.pop(); | 390 get_file_info_callbacks_.pop(); |
| 391 } | 391 } |
| 392 | 392 |
| 393 // Mtpd DBus client. | 393 // Mtpd DBus client. |
| 394 scoped_ptr<chrome::MediaTransferProtocolDaemonClient> mtp_client_; | 394 scoped_ptr<MediaTransferProtocolDaemonClient> mtp_client_; |
| 395 | 395 |
| 396 #if !defined(OS_CHROMEOS) | 396 #if !defined(OS_CHROMEOS) |
| 397 // And a D-Bus session for talking to mtpd. | 397 // And a D-Bus session for talking to mtpd. |
| 398 scoped_refptr<dbus::Bus> session_bus_; | 398 scoped_refptr<dbus::Bus> session_bus_; |
| 399 #endif | 399 #endif |
| 400 | 400 |
| 401 // Device attachment / detachment observers. | 401 // Device attachment / detachment observers. |
| 402 ObserverList<Observer> observers_; | 402 ObserverList<Observer> observers_; |
| 403 | 403 |
| 404 base::WeakPtrFactory<MediaTransferProtocolManagerImpl> weak_ptr_factory_; | 404 base::WeakPtrFactory<MediaTransferProtocolManagerImpl> weak_ptr_factory_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 delete g_media_transfer_protocol_manager; | 443 delete g_media_transfer_protocol_manager; |
| 444 g_media_transfer_protocol_manager = NULL; | 444 g_media_transfer_protocol_manager = NULL; |
| 445 VLOG(1) << "MediaTransferProtocolManager Shutdown completed"; | 445 VLOG(1) << "MediaTransferProtocolManager Shutdown completed"; |
| 446 } | 446 } |
| 447 | 447 |
| 448 // static | 448 // static |
| 449 MediaTransferProtocolManager* MediaTransferProtocolManager::GetInstance() { | 449 MediaTransferProtocolManager* MediaTransferProtocolManager::GetInstance() { |
| 450 return g_media_transfer_protocol_manager; | 450 return g_media_transfer_protocol_manager; |
| 451 } | 451 } |
| 452 | 452 |
| 453 } // namespace chrome | 453 } // namespace device |
| OLD | NEW |