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

Side by Side Diff: chrome/browser/media_gallery/mtp_device_delegate_impl_linux.h

Issue 11348337: Move MTPDeviceDelegateImplLinux worker classes to its own files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments Created 8 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_
6 #define CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/platform_file.h"
12 #include "base/synchronization/waitable_event.h"
13 #include "webkit/fileapi/file_system_file_util.h"
14 #include "webkit/fileapi/media/mtp_device_delegate.h"
15
16 class FilePath;
17
18 namespace base {
19 class SequencedTaskRunner;
20 }
21
22 namespace chrome {
23
24 // This class communicates with the MTP storage to complete the isolated file
25 // system operations. This class contains platform specific code to communicate
26 // with the attached MTP storage. Instantiate this class per MTP storage. This
27 // object is constructed on the UI thread. This object is operated and
28 // destructed on the sequenced task runner thread. ScopedMTPDeviceMapEntry class
29 // manages the lifetime of this object via MTPDeviceMapService class. This class
30 // supports weak pointers because the base class supports weak pointers.
31 class MTPDeviceDelegateImplLinux : public fileapi::MTPDeviceDelegate {
32 public:
33 // Should only be called by ScopedMTPDeviceMapEntry. Use
34 // GetAsWeakPtrOnIOThread() to get a weak pointer instance of this class.
35 // Defer the device initializations until the first file operation request.
36 // Do all the initializations in LazyInit() function.
37 explicit MTPDeviceDelegateImplLinux(const std::string& device_location);
38
39 // MTPDeviceDelegate:
40 virtual base::PlatformFileError GetFileInfo(
41 const FilePath& file_path,
42 base::PlatformFileInfo* file_info) OVERRIDE;
43 virtual scoped_ptr<fileapi::FileSystemFileUtil::AbstractFileEnumerator>
44 CreateFileEnumerator(const FilePath& root,
45 bool recursive) OVERRIDE;
46 virtual base::PlatformFileError CreateSnapshotFile(
47 const FilePath& device_file_path,
48 const FilePath& local_path,
49 base::PlatformFileInfo* file_info) OVERRIDE;
50 virtual base::SequencedTaskRunner* GetMediaTaskRunner() OVERRIDE;
51 virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE;
52 virtual base::WeakPtr<fileapi::MTPDeviceDelegate> GetAsWeakPtrOnIOThread()
53 OVERRIDE;
54
55 private:
56 // Destructed via DeleteDelegateOnTaskRunner(). Do all the clean up in
57 // DeleteDelegateOnTaskRunner().
58 virtual ~MTPDeviceDelegateImplLinux();
59
60 // Opens the device for communication. This function is called on
61 // |media_task_runner_|. Returns true if the device is ready for
62 // communication, else false.
63 bool LazyInit();
64
65 // Deletes the delegate on the task runner thread. Called by
66 // CancelPendingTasksAndDeleteDelegate(). Performs clean up that needs to
67 // happen on |media_task_runner_|.
68 void DeleteDelegateOnTaskRunner();
69
70 // Stores the registered file system device path value. This path does not
71 // correspond to a real device path (E.g.: "/usb:2,2:81282").
72 const std::string device_path_;
73
74 // Stores the device handle returned by
75 // MediaTransferProtocolManager::OpenStorage().
76 std::string device_handle_;
77
78 // Stores a reference to worker pool thread. All requests and response of file
79 // operations are posted on |media_task_runner_|.
80 scoped_refptr<base::SequencedTaskRunner> media_task_runner_;
81
82 // |media_task_runner_| can wait on this event until the requested task is
83 // complete.
84 base::WaitableEvent on_task_completed_event_;
85
86 // Used to notify |media_task_runner_| pending tasks about the shutdown
87 // sequence. Signaled on the IO thread.
88 base::WaitableEvent on_shutdown_event_;
89
90 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux);
91 };
92
93 } // namespace chrome
94
95 #endif // CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698