| OLD | NEW |
| 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_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ |
| 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/supports_user_data.h" | 9 #include "base/supports_user_data.h" |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| 11 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" | 11 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" |
| 12 #include "webkit/browser/webkit_storage_browser_export.h" | 12 #include "webkit/browser/webkit_storage_browser_export.h" |
| 13 #include "webkit/common/quota/quota_types.h" | 13 #include "webkit/common/quota/quota_types.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class SequencedTaskRunner; | 16 class SequencedTaskRunner; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace fileapi { | 19 namespace storage { |
| 20 | 20 |
| 21 class FileSystemContext; | 21 class FileSystemContext; |
| 22 | 22 |
| 23 // A context class which is carried around by FileSystemOperation and | 23 // A context class which is carried around by FileSystemOperation and |
| 24 // its delegated tasks. It is valid to reuse one context instance across | 24 // its delegated tasks. It is valid to reuse one context instance across |
| 25 // multiple operations as far as those operations are supposed to share | 25 // multiple operations as far as those operations are supposed to share |
| 26 // the same context (e.g. use the same task runner, share the quota etc). | 26 // the same context (e.g. use the same task runner, share the quota etc). |
| 27 // Note that the remaining quota bytes (allowed_bytes_growth) may be | 27 // Note that the remaining quota bytes (allowed_bytes_growth) may be |
| 28 // updated during the execution of write operations. | 28 // updated during the execution of write operations. |
| 29 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemOperationContext | 29 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemOperationContext |
| (...skipping 13 matching lines...) Expand all Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Updates the current remaining quota. | 45 // Updates the current remaining quota. |
| 46 // This can be called to update the remaining quota during the operation. | 46 // This can be called to update the remaining quota during the operation. |
| 47 void set_allowed_bytes_growth(const int64& allowed_bytes_growth) { | 47 void set_allowed_bytes_growth(const int64& allowed_bytes_growth) { |
| 48 allowed_bytes_growth_ = allowed_bytes_growth; | 48 allowed_bytes_growth_ = allowed_bytes_growth; |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Returns the current remaining quota. | 51 // Returns the current remaining quota. |
| 52 int64 allowed_bytes_growth() const { return allowed_bytes_growth_; } | 52 int64 allowed_bytes_growth() const { return allowed_bytes_growth_; } |
| 53 quota::QuotaLimitType quota_limit_type() const { return quota_limit_type_; } | 53 storage::QuotaLimitType quota_limit_type() const { return quota_limit_type_; } |
| 54 base::SequencedTaskRunner* task_runner() const { return task_runner_.get(); } | 54 base::SequencedTaskRunner* task_runner() const { return task_runner_.get(); } |
| 55 | 55 |
| 56 ChangeObserverList* change_observers() { return &change_observers_; } | 56 ChangeObserverList* change_observers() { return &change_observers_; } |
| 57 UpdateObserverList* update_observers() { return &update_observers_; } | 57 UpdateObserverList* update_observers() { return &update_observers_; } |
| 58 | 58 |
| 59 // Following setters should be called only on the same thread as the | 59 // Following setters should be called only on the same thread as the |
| 60 // FileSystemOperationContext is created (i.e. are not supposed be updated | 60 // FileSystemOperationContext is created (i.e. are not supposed be updated |
| 61 // after the context's passed onto other task runners). | 61 // after the context's passed onto other task runners). |
| 62 void set_change_observers(const ChangeObserverList& list) { | 62 void set_change_observers(const ChangeObserverList& list) { |
| 63 DCHECK(setter_thread_checker_.CalledOnValidThread()); | 63 DCHECK(setter_thread_checker_.CalledOnValidThread()); |
| 64 change_observers_ = list; | 64 change_observers_ = list; |
| 65 } | 65 } |
| 66 void set_update_observers(const UpdateObserverList& list) { | 66 void set_update_observers(const UpdateObserverList& list) { |
| 67 DCHECK(setter_thread_checker_.CalledOnValidThread()); | 67 DCHECK(setter_thread_checker_.CalledOnValidThread()); |
| 68 update_observers_ = list; | 68 update_observers_ = list; |
| 69 } | 69 } |
| 70 void set_quota_limit_type(quota::QuotaLimitType limit_type) { | 70 void set_quota_limit_type(storage::QuotaLimitType limit_type) { |
| 71 DCHECK(setter_thread_checker_.CalledOnValidThread()); | 71 DCHECK(setter_thread_checker_.CalledOnValidThread()); |
| 72 quota_limit_type_ = limit_type; | 72 quota_limit_type_ = limit_type; |
| 73 } | 73 } |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 scoped_refptr<FileSystemContext> file_system_context_; | 76 scoped_refptr<FileSystemContext> file_system_context_; |
| 77 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 77 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 78 | 78 |
| 79 // The current remaining quota, used by ObfuscatedFileUtil. | 79 // The current remaining quota, used by ObfuscatedFileUtil. |
| 80 int64 allowed_bytes_growth_; | 80 int64 allowed_bytes_growth_; |
| 81 | 81 |
| 82 // The current quota limit type, used by ObfuscatedFileUtil. | 82 // The current quota limit type, used by ObfuscatedFileUtil. |
| 83 quota::QuotaLimitType quota_limit_type_; | 83 storage::QuotaLimitType quota_limit_type_; |
| 84 | 84 |
| 85 // Observers attached to this context. | 85 // Observers attached to this context. |
| 86 ChangeObserverList change_observers_; | 86 ChangeObserverList change_observers_; |
| 87 UpdateObserverList update_observers_; | 87 UpdateObserverList update_observers_; |
| 88 | 88 |
| 89 // Used to check its setters are not called on arbitrary thread. | 89 // Used to check its setters are not called on arbitrary thread. |
| 90 base::ThreadChecker setter_thread_checker_; | 90 base::ThreadChecker setter_thread_checker_; |
| 91 | 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationContext); | 92 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationContext); |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 } // namespace fileapi | 95 } // namespace storage |
| 96 | 96 |
| 97 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ | 97 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ |
| OLD | NEW |