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

Side by Side Diff: webkit/fileapi/file_system_operation_context.h

Issue 11358243: Redesigned and refactored ScopedMTPDeviceMapEntry, MTPDeviceMapService & MTPDeviceDelegate classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test Created 8 years, 1 month 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 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h"
9 #include "webkit/fileapi/file_system_context.h" 10 #include "webkit/fileapi/file_system_context.h"
10 #include "webkit/fileapi/media/mtp_device_file_system_config.h" 11 #include "webkit/fileapi/media/mtp_device_file_system_config.h"
11 #include "webkit/fileapi/task_runner_bound_observer_list.h" 12 #include "webkit/fileapi/task_runner_bound_observer_list.h"
12 #include "webkit/storage/webkit_storage_export.h" 13 #include "webkit/storage/webkit_storage_export.h"
13 14
14 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) 15 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
15 #include "webkit/fileapi/media/mtp_device_delegate.h" 16 #include "webkit/fileapi/media/mtp_device_delegate.h"
16 #endif 17 #endif
17 18
18 namespace base { 19 namespace base {
(...skipping 12 matching lines...) Expand all
31 FileSystemContext* file_system_context() const { 32 FileSystemContext* file_system_context() const {
32 return file_system_context_.get(); 33 return file_system_context_.get();
33 } 34 }
34 35
35 void set_allowed_bytes_growth(const int64& allowed_bytes_growth) { 36 void set_allowed_bytes_growth(const int64& allowed_bytes_growth) {
36 allowed_bytes_growth_ = allowed_bytes_growth; 37 allowed_bytes_growth_ = allowed_bytes_growth;
37 } 38 }
38 int64 allowed_bytes_growth() const { return allowed_bytes_growth_; } 39 int64 allowed_bytes_growth() const { return allowed_bytes_growth_; }
39 40
40 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) 41 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
42 // Called on IO thread.
41 void set_mtp_device_delegate(MTPDeviceDelegate* delegate) { 43 void set_mtp_device_delegate(MTPDeviceDelegate* delegate) {
42 mtp_device_delegate_ = delegate; 44 mtp_device_delegate_ = delegate->GetAsWeakPtrOnIOThread();
Lei Zhang 2012/11/21 01:33:30 This is no longer a simple setter if you call GetA
kmadhusu 2012/11/21 04:09:53 sure. Done.
43 } 45 }
44 46
45 MTPDeviceDelegate* mtp_device_delegate() const { 47 // Caller of this function should dereference the delegate only on media
46 return mtp_device_delegate_.get(); 48 // sequenced task runner thread.
49 base::WeakPtr<MTPDeviceDelegate> mtp_device_delegate() const {
50 return mtp_device_delegate_;
47 } 51 }
48 #endif 52 #endif
49 53
50 // Returns TaskRunner which the operation is performed on. 54 // Returns TaskRunner which the operation is performed on.
51 base::SequencedTaskRunner* task_runner() const { 55 base::SequencedTaskRunner* task_runner() const {
52 return task_runner_.get(); 56 return task_runner_.get();
53 } 57 }
54 58
55 // Overrides TaskRunner which the operation is performed on. 59 // Overrides TaskRunner which the operation is performed on.
56 // file_system_context_->task_runners()->file_task_runner() is used otherwise. 60 // file_system_context_->task_runners()->file_task_runner() is used otherwise.
(...skipping 27 matching lines...) Expand all
84 scoped_refptr<base::SequencedTaskRunner> task_runner_; 88 scoped_refptr<base::SequencedTaskRunner> task_runner_;
85 89
86 int64 allowed_bytes_growth_; 90 int64 allowed_bytes_growth_;
87 MediaPathFilter* media_path_filter_; 91 MediaPathFilter* media_path_filter_;
88 92
89 AccessObserverList access_observers_; 93 AccessObserverList access_observers_;
90 ChangeObserverList change_observers_; 94 ChangeObserverList change_observers_;
91 UpdateObserverList update_observers_; 95 UpdateObserverList update_observers_;
92 96
93 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) 97 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
94 // Store the current mtp device delegate. 98 // The media transfer protocol(MTP) device delegate.
95 scoped_refptr<MTPDeviceDelegate> mtp_device_delegate_; 99 // Set on IO thread and dereferenced on media sequenced task runner thread.
100 base::WeakPtr<MTPDeviceDelegate> mtp_device_delegate_;
96 #endif 101 #endif
97 }; 102 };
98 103
99 } // namespace fileapi 104 } // namespace fileapi
100 105
101 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ 106 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698