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

Side by Side Diff: chrome/browser/chromeos/disks/mock_disk_mount_manager.cc

Issue 10830003: Extract and dispatch device uuid in media device attached notification message. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 8 years, 5 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 | Annotate | Revision Log
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 "chrome/browser/chromeos/disks/mock_disk_mount_manager.h" 5 #include "chrome/browser/chromeos/disks/mock_disk_mount_manager.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 10
11 using content::BrowserThread; 11 using content::BrowserThread;
12 using testing::_; 12 using testing::_;
13 using testing::AnyNumber; 13 using testing::AnyNumber;
14 using testing::Invoke; 14 using testing::Invoke;
15 using testing::ReturnRef; 15 using testing::ReturnRef;
16 16
17 namespace chromeos { 17 namespace chromeos {
18 namespace disks { 18 namespace disks {
19 19
20 namespace { 20 namespace {
21 21
22 const char* kTestSystemPath = "/this/system/path"; 22 const char* kTestSystemPath = "/this/system/path";
23 const char* kTestSystemPathPrefix = "/this/system"; 23 const char* kTestSystemPathPrefix = "/this/system";
24 const char* kTestDevicePath = "/this/device/path"; 24 const char* kTestDevicePath = "/this/device/path";
25 const char* kTestMountPath = "/media/foofoo"; 25 const char* kTestMountPath = "/media/foofoo";
26 const char* kTestFilePath = "/this/file/path"; 26 const char* kTestFilePath = "/this/file/path";
27 const char* kTestDeviceLabel = "A label"; 27 const char* kTestDeviceLabel = "A label";
28 const char* kTestDriveLabel = "Another label"; 28 const char* kTestDriveLabel = "Another label";
29 const char* kTestUuid = "FFFF-FFFF";
29 30
30 } // namespace 31 } // namespace
31 32
32 void MockDiskMountManager::AddObserverInternal( 33 void MockDiskMountManager::AddObserverInternal(
33 DiskMountManager::Observer* observer) { 34 DiskMountManager::Observer* observer) {
34 observers_.AddObserver(observer); 35 observers_.AddObserver(observer);
35 } 36 }
36 37
37 void MockDiskMountManager::RemoveObserverInternal( 38 void MockDiskMountManager::RemoveObserverInternal(
38 DiskMountManager::Observer* observer) { 39 DiskMountManager::Observer* observer) {
(...skipping 14 matching lines...) Expand all
53 } 54 }
54 55
55 void MockDiskMountManager::NotifyDeviceInsertEvents() { 56 void MockDiskMountManager::NotifyDeviceInsertEvents() {
56 scoped_ptr<DiskMountManager::Disk> disk1(new DiskMountManager::Disk( 57 scoped_ptr<DiskMountManager::Disk> disk1(new DiskMountManager::Disk(
57 std::string(kTestDevicePath), 58 std::string(kTestDevicePath),
58 std::string(), 59 std::string(),
59 std::string(kTestSystemPath), 60 std::string(kTestSystemPath),
60 std::string(kTestFilePath), 61 std::string(kTestFilePath),
61 std::string(), 62 std::string(),
62 std::string(kTestDriveLabel), 63 std::string(kTestDriveLabel),
64 std::string(kTestUuid),
63 std::string(kTestSystemPathPrefix), 65 std::string(kTestSystemPathPrefix),
64 DEVICE_TYPE_USB, 66 DEVICE_TYPE_USB,
65 4294967295U, 67 4294967295U,
66 false, // is_parent 68 false, // is_parent
67 false, // is_read_only 69 false, // is_read_only
68 true, // has_media 70 true, // has_media
69 false, // on_boot_device 71 false, // on_boot_device
70 false)); // is_hidden 72 false)); // is_hidden
71 73
72 disks_.clear(); 74 disks_.clear();
(...skipping 10 matching lines...) Expand all
83 NotifyDiskChanged(event, disk1.get()); 85 NotifyDiskChanged(event, disk1.get());
84 86
85 // Disk Changed 87 // Disk Changed
86 scoped_ptr<DiskMountManager::Disk> disk2(new DiskMountManager::Disk( 88 scoped_ptr<DiskMountManager::Disk> disk2(new DiskMountManager::Disk(
87 std::string(kTestDevicePath), 89 std::string(kTestDevicePath),
88 std::string(kTestMountPath), 90 std::string(kTestMountPath),
89 std::string(kTestSystemPath), 91 std::string(kTestSystemPath),
90 std::string(kTestFilePath), 92 std::string(kTestFilePath),
91 std::string(kTestDeviceLabel), 93 std::string(kTestDeviceLabel),
92 std::string(kTestDriveLabel), 94 std::string(kTestDriveLabel),
95 std::string(kTestUuid),
93 std::string(kTestSystemPathPrefix), 96 std::string(kTestSystemPathPrefix),
94 DEVICE_TYPE_MOBILE, 97 DEVICE_TYPE_MOBILE,
95 1073741824, 98 1073741824,
96 false, // is_parent 99 false, // is_parent
97 false, // is_read_only 100 false, // is_read_only
98 true, // has_media 101 true, // has_media
99 false, // on_boot_device 102 false, // on_boot_device
100 false)); // is_hidden 103 false)); // is_hidden
101 disks_.clear(); 104 disks_.clear();
102 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>( 105 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>(
103 std::string(kTestDevicePath), disk2.get())); 106 std::string(kTestDevicePath), disk2.get()));
104 event = MOUNT_DISK_CHANGED; 107 event = MOUNT_DISK_CHANGED;
105 NotifyDiskChanged(event, disk2.get()); 108 NotifyDiskChanged(event, disk2.get());
106 } 109 }
107 110
108 void MockDiskMountManager::NotifyDeviceRemoveEvents() { 111 void MockDiskMountManager::NotifyDeviceRemoveEvents() {
109 scoped_ptr<DiskMountManager::Disk> disk(new DiskMountManager::Disk( 112 scoped_ptr<DiskMountManager::Disk> disk(new DiskMountManager::Disk(
110 std::string(kTestDevicePath), 113 std::string(kTestDevicePath),
111 std::string(kTestMountPath), 114 std::string(kTestMountPath),
112 std::string(kTestSystemPath), 115 std::string(kTestSystemPath),
113 std::string(kTestFilePath), 116 std::string(kTestFilePath),
114 std::string(kTestDeviceLabel), 117 std::string(kTestDeviceLabel),
118 std::string(kTestUuid),
115 std::string(kTestDriveLabel), 119 std::string(kTestDriveLabel),
116 std::string(kTestSystemPathPrefix), 120 std::string(kTestSystemPathPrefix),
117 DEVICE_TYPE_SD, 121 DEVICE_TYPE_SD,
118 1073741824, 122 1073741824,
119 false, // is_parent 123 false, // is_parent
120 false, // is_read_only 124 false, // is_read_only
121 true, // has_media 125 true, // has_media
122 false, // on_boot_device 126 false, // on_boot_device
123 false)); // is_hidden 127 false)); // is_hidden
124 disks_.clear(); 128 disks_.clear();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 void MockDiskMountManager::NotifyDeviceChanged(DiskMountManagerEventType event, 164 void MockDiskMountManager::NotifyDeviceChanged(DiskMountManagerEventType event,
161 const std::string& path) { 165 const std::string& path) {
162 // Make sure we run on UI thread. 166 // Make sure we run on UI thread.
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
164 168
165 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(event, path)); 169 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(event, path));
166 } 170 }
167 171
168 } // namespace disks 172 } // namespace disks
169 } // namespace chromeos 173 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698