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

Side by Side Diff: chrome/browser/chromeos/cros/mock_mount_library.cc

Issue 6674043: Rewritten MountLibrary to work with non-blocking mount API calls in libcros.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/cros/mock_mount_library.h" 5 #include "chrome/browser/chromeos/cros/mock_mount_library.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 "chrome/browser/chromeos/cros/cros_library.h" 9 #include "chrome/browser/chromeos/cros/cros_library.h"
10 #include "content/browser/browser_thread.h" 10 #include "content/browser/browser_thread.h"
(...skipping 24 matching lines...) Expand all
35 ON_CALL(*this, disks()) 35 ON_CALL(*this, disks())
36 .WillByDefault(Invoke(this, &MockMountLibrary::disksInternal)); 36 .WillByDefault(Invoke(this, &MockMountLibrary::disksInternal));
37 } 37 }
38 38
39 MockMountLibrary::~MockMountLibrary() { 39 MockMountLibrary::~MockMountLibrary() {
40 40
41 } 41 }
42 42
43 void MockMountLibrary::FireDeviceInsertEvents() { 43 void MockMountLibrary::FireDeviceInsertEvents() {
44 44
45 scoped_ptr<MountLibrary::Disk> disk1(new MountLibrary::Disk(
46 std::string(kTestDevicePath),
47 std::string(),
48 std::string(kTestSystemPath),
49 false,
50 true,
51 false));
52
45 disks_.clear(); 53 disks_.clear();
46 54 disks_.insert(std::pair<std::string, MountLibrary::Disk*>(
47 disks_.push_back(Disk(kTestDevicePath, "", kTestSystemPath, false, true)); 55 std::string(kTestDevicePath), disk1.get()));
48 56
49 // Device Added 57 // Device Added
50 chromeos::MountEventType evt; 58 chromeos::MountLibraryEventType evt;
51 evt = chromeos::DEVICE_ADDED; 59 evt = chromeos::MOUNT_DEVICE_ADDED;
52 UpdateMountStatus(evt, kTestSystemPath); 60 UpdateDeviceChanged(evt, kTestSystemPath);
53 61
54 // Disk Added 62 // Disk Added
55 evt = chromeos::DISK_ADDED; 63 evt = chromeos::MOUNT_DISK_ADDED;
56 UpdateMountStatus(evt, kTestDevicePath); 64 UpdateDiskChanged(evt, disk1.get());
57 65
58 // Disk Changed 66 // Disk Changed
67 scoped_ptr<MountLibrary::Disk> disk2(new MountLibrary::Disk(
68 std::string(kTestDevicePath),
69 std::string(kTestMountPath),
70 std::string(kTestSystemPath),
71 false,
72 true,
73 false));
59 disks_.clear(); 74 disks_.clear();
60 disks_.push_back(Disk( 75 disks_.insert(std::pair<std::string, MountLibrary::Disk*>(
61 kTestDevicePath, kTestMountPath, kTestSystemPath, false, true)); 76 std::string(kTestDevicePath), disk2.get()));
62 evt = chromeos::DISK_CHANGED; 77 evt = chromeos::MOUNT_DISK_CHANGED;
63 UpdateMountStatus(evt, kTestDevicePath); 78 UpdateDiskChanged(evt, disk2.get());
64 } 79 }
65 80
66 void MockMountLibrary::FireDeviceRemoveEvents() { 81 void MockMountLibrary::FireDeviceRemoveEvents() {
82 scoped_ptr<MountLibrary::Disk> disk(new MountLibrary::Disk(
83 std::string(kTestDevicePath),
84 std::string(kTestMountPath),
85 std::string(kTestSystemPath),
86 false,
87 true,
88 false));
67 disks_.clear(); 89 disks_.clear();
68 chromeos::MountEventType evt; 90 disks_.insert(std::pair<std::string, MountLibrary::Disk*>(
69 evt = chromeos::DISK_REMOVED; 91 std::string(kTestDevicePath), disk.get()));
70 UpdateMountStatus(evt, kTestDevicePath); 92 UpdateDiskChanged(chromeos::MOUNT_DISK_REMOVED, disk.get());
71 } 93 }
72 94
73 void MockMountLibrary::UpdateMountStatus(MountEventType evt, 95 void MockMountLibrary::UpdateDiskChanged(MountLibraryEventType evt,
74 const std::string& path) { 96 const MountLibrary::Disk* disk) {
75 // Make sure we run on UI thread. 97 // Make sure we run on UI thread.
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
77 99
78 FOR_EACH_OBSERVER(Observer, observers_, MountChanged(this, evt, path)); 100 FOR_EACH_OBSERVER(Observer, observers_, DiskChanged(evt, disk));
101 }
102
103
104 void MockMountLibrary::UpdateDeviceChanged(MountLibraryEventType evt,
105 const std::string& path) {
106 // Make sure we run on UI thread.
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
108
109 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(evt, path));
79 } 110 }
80 111
81 } // namespace chromeos 112 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/mock_mount_library.h ('k') | chrome/browser/chromeos/cros/mount_library.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698