Update V8 to version 4.5.7.
[chromium-blink-merge.git] / components / storage_monitor / image_capture_device.h
blob55dc1fe56133111aa4428278cac8c98c966f922b
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_STORAGE_MONITOR_IMAGE_CAPTURE_DEVICE_H_
6 #define COMPONENTS_STORAGE_MONITOR_IMAGE_CAPTURE_DEVICE_H_
8 #import <Foundation/Foundation.h>
9 #import <ImageCaptureCore/ImageCaptureCore.h>
11 #include "base/files/file.h"
12 #include "base/files/file_path.h"
13 #include "base/mac/cocoa_protocols.h"
14 #include "base/mac/foundation_util.h"
15 #include "base/mac/scoped_nsobject.h"
16 #include "base/memory/ref_counted.h"
17 #include "base/memory/weak_ptr.h"
18 #include "base/strings/string_util.h"
19 #include "base/strings/sys_string_conversions.h"
20 #include "base/synchronization/lock.h"
22 namespace storage_monitor {
24 // Clients use this listener interface to get notifications about
25 // events happening as a particular ImageCapture device is interacted with.
26 // Clients drive the interaction through the ImageCaptureDeviceManager
27 // and the ImageCaptureDevice classes, and get notifications of
28 // events through this interface.
29 class ImageCaptureDeviceListener {
30 public:
31 virtual ~ImageCaptureDeviceListener() {}
33 // Get a notification that a particular item has been found on the device.
34 // These calls will come automatically after a new device is initialized.
35 // Names are in relative path form, so subdirectories and files in them will
36 // be passed as "dir/subdir/filename". These same relative filenames should
37 // be used as keys to download files.
38 virtual void ItemAdded(const std::string& name,
39 const base::File::Info& info) = 0;
41 // Called when there are no more items to retrieve.
42 virtual void NoMoreItems() = 0;
44 // Called upon completion of a file download request.
45 // Note: in NOT_FOUND error case, may be called inline with the download
46 // request.
47 virtual void DownloadedFile(const std::string& name,
48 base::File::Error error) = 0;
50 // Called to let the client know the device is removed. The client should
51 // set the ImageCaptureDevice listener to null upon receiving this call.
52 virtual void DeviceRemoved() = 0;
55 } // namespace storage_monitor
57 // Interface to a camera device found by ImageCaptureCore. This class manages a
58 // session to the camera and provides the backing interactions to present the
59 // media files on it to the filesystem delegate. FilePaths will be artificial,
60 // like "/$device_id/" + name.
61 // Note that all interactions with this class must happen on the UI thread.
62 @interface ImageCaptureDevice
63 : NSObject<ICCameraDeviceDelegate, ICCameraDeviceDownloadDelegate> {
64 @private
65 base::scoped_nsobject<ICCameraDevice> camera_;
66 base::WeakPtr<storage_monitor::ImageCaptureDeviceListener> listener_;
67 bool closing_;
70 - (id)initWithCameraDevice:(ICCameraDevice*)cameraDevice;
71 - (void)setListener:
72 (base::WeakPtr<storage_monitor::ImageCaptureDeviceListener>)listener;
73 - (void)open;
74 - (void)close;
76 - (void)eject;
78 // Download the given file |name| to the provided |local_path|. Completion
79 // notice will be sent to the listener's DownloadedFile method. The name
80 // should be of the same form as those sent to the listener's ItemAdded method.
81 - (void)downloadFile:(const std::string&)name
82 localPath:(const base::FilePath&)localPath;
84 @end
86 #endif // COMPONENTS_STORAGE_MONITOR_IMAGE_CAPTURE_DEVICE_H_