Chromium Code Reviews| Index: webkit/fileapi/file_system_operation_context.h |
| diff --git a/webkit/fileapi/file_system_operation_context.h b/webkit/fileapi/file_system_operation_context.h |
| index 067e0d8886b81dd64345fd19e3767233c92b8e7e..932ba323ba826ce3966a14d6b52f51af0e488388 100644 |
| --- a/webkit/fileapi/file_system_operation_context.h |
| +++ b/webkit/fileapi/file_system_operation_context.h |
| @@ -6,6 +6,7 @@ |
| #define WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ |
| #include "base/memory/ref_counted.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "webkit/fileapi/file_system_context.h" |
| #include "webkit/fileapi/media/mtp_device_file_system_config.h" |
| #include "webkit/fileapi/task_runner_bound_observer_list.h" |
| @@ -38,12 +39,15 @@ class WEBKIT_STORAGE_EXPORT_PRIVATE FileSystemOperationContext { |
| int64 allowed_bytes_growth() const { return allowed_bytes_growth_; } |
| #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) |
| + // Called on IO thread. |
| void set_mtp_device_delegate(MTPDeviceDelegate* delegate) { |
| - mtp_device_delegate_ = delegate; |
| + 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.
|
| } |
| - MTPDeviceDelegate* mtp_device_delegate() const { |
| - return mtp_device_delegate_.get(); |
| + // Caller of this function should dereference the delegate only on media |
| + // sequenced task runner thread. |
| + base::WeakPtr<MTPDeviceDelegate> mtp_device_delegate() const { |
| + return mtp_device_delegate_; |
| } |
| #endif |
| @@ -91,8 +95,9 @@ class WEBKIT_STORAGE_EXPORT_PRIVATE FileSystemOperationContext { |
| UpdateObserverList update_observers_; |
| #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) |
| - // Store the current mtp device delegate. |
| - scoped_refptr<MTPDeviceDelegate> mtp_device_delegate_; |
| + // The media transfer protocol(MTP) device delegate. |
| + // Set on IO thread and dereferenced on media sequenced task runner thread. |
| + base::WeakPtr<MTPDeviceDelegate> mtp_device_delegate_; |
| #endif |
| }; |