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

Side by Side Diff: chrome/browser/storage_monitor/image_capture_device_manager.mm

Issue 23727009: Cleanup: Remove chrome namespace for storage monitor and media galleries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nit Created 7 years, 3 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/storage_monitor/image_capture_device_manager.h" 5 #include "chrome/browser/storage_monitor/image_capture_device_manager.h"
6 6
7 #import <ImageCaptureCore/ImageCaptureCore.h> 7 #import <ImageCaptureCore/ImageCaptureCore.h>
8 8
9 #import "chrome/browser/storage_monitor/image_capture_device.h" 9 #import "chrome/browser/storage_monitor/image_capture_device.h"
10 #include "chrome/browser/storage_monitor/storage_info.h" 10 #include "chrome/browser/storage_monitor/storage_info.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 12
13 namespace { 13 namespace {
14 14
15 chrome::ImageCaptureDeviceManager* g_image_capture_device_manager = NULL; 15 ImageCaptureDeviceManager* g_image_capture_device_manager = NULL;
16 16
17 } // namespace 17 } // namespace
18 18
19 // This class is the surface for the Mac ICDeviceBrowser ImageCaptureCore API. 19 // This class is the surface for the Mac ICDeviceBrowser ImageCaptureCore API.
20 // Owned by the ChromeBrowserParts and has browser process lifetime. Upon 20 // Owned by the ChromeBrowserParts and has browser process lifetime. Upon
21 // creation, it gets a list of attached media volumes (asynchronously) which 21 // creation, it gets a list of attached media volumes (asynchronously) which
22 // it will eventually forward to StorageMonitor. It will also 22 // it will eventually forward to StorageMonitor. It will also
23 // set up an ImageCaptureCore listener to be told when new devices/volumes 23 // set up an ImageCaptureCore listener to be told when new devices/volumes
24 // are discovered and existing ones are removed. 24 // are discovered and existing ones are removed.
25 @interface ImageCaptureDeviceManagerImpl 25 @interface ImageCaptureDeviceManagerImpl
26 : NSObject<ICDeviceBrowserDelegate> { 26 : NSObject<ICDeviceBrowserDelegate> {
27 @private 27 @private
28 base::scoped_nsobject<ICDeviceBrowser> deviceBrowser_; 28 base::scoped_nsobject<ICDeviceBrowser> deviceBrowser_;
29 base::scoped_nsobject<NSMutableArray> cameras_; 29 base::scoped_nsobject<NSMutableArray> cameras_;
30 30
31 // Guaranteed to outlive this class. 31 // Guaranteed to outlive this class.
32 // TODO(gbillock): Update when ownership chains go up through 32 // TODO(gbillock): Update when ownership chains go up through
33 // a StorageMonitor subclass. 33 // a StorageMonitor subclass.
34 chrome::StorageMonitor::Receiver* notifications_; 34 StorageMonitor::Receiver* notifications_;
35 } 35 }
36 36
37 - (void)setNotifications:(chrome::StorageMonitor::Receiver*)notifications; 37 - (void)setNotifications:(StorageMonitor::Receiver*)notifications;
38 - (void)close; 38 - (void)close;
39 39
40 // The UUIDs passed here are available in the device attach notifications. 40 // The UUIDs passed here are available in the device attach notifications.
41 // They're gotten by cracking the device ID and taking the unique ID output. 41 // They're gotten by cracking the device ID and taking the unique ID output.
42 - (ImageCaptureDevice*)deviceForUUID:(const std::string&)uuid; 42 - (ImageCaptureDevice*)deviceForUUID:(const std::string&)uuid;
43 43
44 @end 44 @end
45 45
46 @implementation ImageCaptureDeviceManagerImpl 46 @implementation ImageCaptureDeviceManagerImpl
47 47
48 - (id)init { 48 - (id)init {
49 if ((self = [super init])) { 49 if ((self = [super init])) {
50 cameras_.reset([[NSMutableArray alloc] init]); 50 cameras_.reset([[NSMutableArray alloc] init]);
51 notifications_ = NULL; 51 notifications_ = NULL;
52 52
53 deviceBrowser_.reset([[ICDeviceBrowser alloc] init]); 53 deviceBrowser_.reset([[ICDeviceBrowser alloc] init]);
54 [deviceBrowser_ setDelegate:self]; 54 [deviceBrowser_ setDelegate:self];
55 [deviceBrowser_ setBrowsedDeviceTypeMask: 55 [deviceBrowser_ setBrowsedDeviceTypeMask:
56 ICDeviceTypeMaskCamera | ICDeviceLocationTypeMaskLocal]; 56 ICDeviceTypeMaskCamera | ICDeviceLocationTypeMaskLocal];
57 [deviceBrowser_ start]; 57 [deviceBrowser_ start];
58 } 58 }
59 return self; 59 return self;
60 } 60 }
61 61
62 - (void)setNotifications:(chrome::StorageMonitor::Receiver*)notifications { 62 - (void)setNotifications:(StorageMonitor::Receiver*)notifications {
63 notifications_ = notifications; 63 notifications_ = notifications;
64 } 64 }
65 65
66 - (void)close { 66 - (void)close {
67 [deviceBrowser_ setDelegate:nil]; 67 [deviceBrowser_ setDelegate:nil];
68 [deviceBrowser_ stop]; 68 [deviceBrowser_ stop];
69 deviceBrowser_.reset(); 69 deviceBrowser_.reset();
70 cameras_.reset(); 70 cameras_.reset();
71 } 71 }
72 72
(...skipping 18 matching lines...) Expand all
91 // by Mac's removable storage watcher. 91 // by Mac's removable storage watcher.
92 if ([addedDevice.transportType isEqualToString:ICTransportTypeMassStorage]) 92 if ([addedDevice.transportType isEqualToString:ICTransportTypeMassStorage])
93 return; 93 return;
94 94
95 ICCameraDevice* cameraDevice = 95 ICCameraDevice* cameraDevice =
96 base::mac::ObjCCastStrict<ICCameraDevice>(addedDevice); 96 base::mac::ObjCCastStrict<ICCameraDevice>(addedDevice);
97 97
98 [cameras_ addObject:addedDevice]; 98 [cameras_ addObject:addedDevice];
99 99
100 // TODO(gbillock): use [cameraDevice mountPoint] here when possible. 100 // TODO(gbillock): use [cameraDevice mountPoint] here when possible.
101 chrome::StorageInfo info( 101 StorageInfo info(
102 chrome::StorageInfo::MakeDeviceId( 102 StorageInfo::MakeDeviceId(
103 chrome::StorageInfo::MAC_IMAGE_CAPTURE, 103 StorageInfo::MAC_IMAGE_CAPTURE,
104 base::SysNSStringToUTF8([cameraDevice UUIDString])), 104 base::SysNSStringToUTF8([cameraDevice UUIDString])),
105 base::SysNSStringToUTF16([cameraDevice name]), 105 base::SysNSStringToUTF16([cameraDevice name]),
106 "", 106 "",
107 string16(), 107 string16(),
108 string16(), 108 string16(),
109 string16(), 109 string16(),
110 0); 110 0);
111 notifications_->ProcessAttach(info); 111 notifications_->ProcessAttach(info);
112 } 112 }
113 113
114 - (void)deviceBrowser:(ICDeviceBrowser*)browser 114 - (void)deviceBrowser:(ICDeviceBrowser*)browser
115 didRemoveDevice:(ICDevice*)device 115 didRemoveDevice:(ICDevice*)device
116 moreGoing:(BOOL)moreGoing { 116 moreGoing:(BOOL)moreGoing {
117 if (!(device.type & ICDeviceTypeCamera)) 117 if (!(device.type & ICDeviceTypeCamera))
118 return; 118 return;
119 119
120 std::string uuid = base::SysNSStringToUTF8([device UUIDString]); 120 std::string uuid = base::SysNSStringToUTF8([device UUIDString]);
121 121
122 // May delete |device|. 122 // May delete |device|.
123 [cameras_ removeObject:device]; 123 [cameras_ removeObject:device];
124 124
125 notifications_->ProcessDetach( 125 notifications_->ProcessDetach(
126 chrome::StorageInfo::MakeDeviceId( 126 StorageInfo::MakeDeviceId(StorageInfo::MAC_IMAGE_CAPTURE, uuid));
127 chrome::StorageInfo::MAC_IMAGE_CAPTURE, uuid));
128 } 127 }
129 128
130 @end // ImageCaptureDeviceManagerImpl 129 @end // ImageCaptureDeviceManagerImpl
131 130
132 namespace chrome {
133
134 ImageCaptureDeviceManager::ImageCaptureDeviceManager() { 131 ImageCaptureDeviceManager::ImageCaptureDeviceManager() {
135 device_browser_.reset([[ImageCaptureDeviceManagerImpl alloc] init]); 132 device_browser_.reset([[ImageCaptureDeviceManagerImpl alloc] init]);
136 g_image_capture_device_manager = this; 133 g_image_capture_device_manager = this;
137 } 134 }
138 135
139 ImageCaptureDeviceManager::~ImageCaptureDeviceManager() { 136 ImageCaptureDeviceManager::~ImageCaptureDeviceManager() {
140 g_image_capture_device_manager = NULL; 137 g_image_capture_device_manager = NULL;
141 [device_browser_ close]; 138 [device_browser_ close];
142 } 139 }
143 140
(...skipping 16 matching lines...) Expand all
160 ImageCaptureDevice* ImageCaptureDeviceManager::deviceForUUID( 157 ImageCaptureDevice* ImageCaptureDeviceManager::deviceForUUID(
161 const std::string& uuid) { 158 const std::string& uuid) {
162 ImageCaptureDeviceManagerImpl* manager = 159 ImageCaptureDeviceManagerImpl* manager =
163 g_image_capture_device_manager->device_browser_; 160 g_image_capture_device_manager->device_browser_;
164 return [manager deviceForUUID:uuid]; 161 return [manager deviceForUUID:uuid];
165 } 162 }
166 163
167 id<ICDeviceBrowserDelegate> ImageCaptureDeviceManager::device_browser() { 164 id<ICDeviceBrowserDelegate> ImageCaptureDeviceManager::device_browser() {
168 return device_browser_.get(); 165 return device_browser_.get();
169 } 166 }
170
171 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698