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 "device/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/common/chrome_switches.h" | |
18 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
19 #include "device/media_transfer_protocol/media_transfer_protocol_daemon_client.h
" | 18 #include "device/media_transfer_protocol/media_transfer_protocol_daemon_client.h
" |
20 #include "device/media_transfer_protocol/mtp_file_entry.pb.h" | 19 #include "device/media_transfer_protocol/mtp_file_entry.pb.h" |
21 #include "device/media_transfer_protocol/mtp_storage_info.pb.h" | 20 #include "device/media_transfer_protocol/mtp_storage_info.pb.h" |
22 | 21 |
23 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
24 #include "chromeos/dbus/dbus_thread_manager.h" | 23 #include "chromeos/dbus/dbus_thread_manager.h" |
25 #else | 24 #else |
26 #include "dbus/bus.h" | 25 #include "dbus/bus.h" |
27 #endif | 26 #endif |
28 | 27 |
29 using content::BrowserThread; | 28 using content::BrowserThread; |
30 | 29 |
31 namespace device { | 30 namespace device { |
32 | 31 |
33 namespace { | 32 namespace { |
34 | 33 |
35 MediaTransferProtocolManager* g_media_transfer_protocol_manager = NULL; | 34 MediaTransferProtocolManager* g_media_transfer_protocol_manager = NULL; |
36 | 35 |
37 // The MediaTransferProtocolManager implementation. | 36 // The MediaTransferProtocolManager implementation. |
38 class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager { | 37 class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager { |
39 public: | 38 public: |
40 MediaTransferProtocolManagerImpl() : weak_ptr_factory_(this) { | 39 MediaTransferProtocolManagerImpl() : weak_ptr_factory_(this) { |
41 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) | |
42 return; | |
43 | |
44 dbus::Bus* bus = NULL; | 40 dbus::Bus* bus = NULL; |
45 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
46 chromeos::DBusThreadManager* dbus_thread_manager = | 42 chromeos::DBusThreadManager* dbus_thread_manager = |
47 chromeos::DBusThreadManager::Get(); | 43 chromeos::DBusThreadManager::Get(); |
48 bus = dbus_thread_manager->GetSystemBus(); | 44 bus = dbus_thread_manager->GetSystemBus(); |
49 if (!bus) | 45 if (!bus) |
50 return; | 46 return; |
51 #else | 47 #else |
52 dbus::Bus::Options options; | 48 dbus::Bus::Options options; |
53 options.bus_type = dbus::Bus::SYSTEM; | 49 options.bus_type = dbus::Bus::SYSTEM; |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 g_media_transfer_protocol_manager = NULL; | 440 g_media_transfer_protocol_manager = NULL; |
445 VLOG(1) << "MediaTransferProtocolManager Shutdown completed"; | 441 VLOG(1) << "MediaTransferProtocolManager Shutdown completed"; |
446 } | 442 } |
447 | 443 |
448 // static | 444 // static |
449 MediaTransferProtocolManager* MediaTransferProtocolManager::GetInstance() { | 445 MediaTransferProtocolManager* MediaTransferProtocolManager::GetInstance() { |
450 return g_media_transfer_protocol_manager; | 446 return g_media_transfer_protocol_manager; |
451 } | 447 } |
452 | 448 |
453 } // namespace device | 449 } // namespace device |
OLD | NEW |