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

Unified Diff: webkit/fileapi/file_system_operation_context.h

Issue 15453002: Add thread checker to FileSystemOperationContext to allow setters called only on initialization thr… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webkit/fileapi/file_system_operation_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5154a730861c5b9cdf2d2b1abade6f4482a3061f..7b7ba40abfa4f4799f2d5578b1364f3814c07b5e 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/supports_user_data.h"
+#include "base/threading/thread_checker.h"
#include "webkit/fileapi/task_runner_bound_observer_list.h"
#include "webkit/quota/quota_types.h"
#include "webkit/storage/webkit_storage_export.h"
@@ -40,6 +41,7 @@ class WEBKIT_STORAGE_EXPORT_PRIVATE FileSystemOperationContext
}
// Updates the current remaining quota.
+ // This can be called to update the remaining quota during the operation.
void set_allowed_bytes_growth(const int64& allowed_bytes_growth) {
allowed_bytes_growth_ = allowed_bytes_growth;
}
@@ -60,12 +62,35 @@ class WEBKIT_STORAGE_EXPORT_PRIVATE FileSystemOperationContext
AccessObserverList* access_observers() { return &access_observers_; }
UpdateObserverList* update_observers() { return &update_observers_; }
+ // Following setters should be called only on the same thread as the
+ // FileSystemOperationContext is created (i.e. are not supposed be updated
+ // after the context's passed onto other task runners).
+ void set_change_observers(const ChangeObserverList& list) {
+ DCHECK(setter_thread_checker_.CalledOnValidThread());
+ change_observers_ = list;
+ }
+ void set_access_observers(const AccessObserverList& list) {
+ DCHECK(setter_thread_checker_.CalledOnValidThread());
+ access_observers_ = list;
+ }
+ void set_update_observers(const UpdateObserverList& list) {
+ DCHECK(setter_thread_checker_.CalledOnValidThread());
+ update_observers_ = list;
+ }
+ void set_quota_limit_type(quota::QuotaLimitType limit_type) {
+ DCHECK(setter_thread_checker_.CalledOnValidThread());
+ quota_limit_type_ = limit_type;
+ }
+
// Gets and sets value-type (or not-owned) variable as UserData.
+ // (SetUserValue can be called only on the same thread as this context
+ // is created as well as other setters.)
template <typename T> T GetUserValue(const char* key) const {
ValueAdapter<T>* v = static_cast<ValueAdapter<T>*>(GetUserData(key));
return v ? v->value() : T();
}
template <typename T> void SetUserValue(const char* key, const T& value) {
+ DCHECK(setter_thread_checker_.CalledOnValidThread());
SetUserData(key, new ValueAdapter<T>(value));
}
@@ -81,31 +106,6 @@ class WEBKIT_STORAGE_EXPORT_PRIVATE FileSystemOperationContext
DISALLOW_COPY_AND_ASSIGN(ValueAdapter);
};
- // Only regular (and test) MountPointProviders can access following setters.
- friend class IsolatedMountPointProvider;
- friend class SandboxMountPointProvider;
- friend class TestMountPointProvider;
-
- // Tests also need access to some setters.
- friend class FileSystemQuotaClientTest;
- friend class LocalFileSystemOperationTest;
- friend class LocalFileSystemOperationWriteTest;
- friend class LocalFileSystemTestOriginHelper;
- friend class ObfuscatedFileUtilTest;
-
- void set_change_observers(const ChangeObserverList& list) {
- change_observers_ = list;
- }
- void set_access_observers(const AccessObserverList& list) {
- access_observers_ = list;
- }
- void set_update_observers(const UpdateObserverList& list) {
- update_observers_ = list;
- }
- void set_quota_limit_type(quota::QuotaLimitType limit_type) {
- quota_limit_type_ = limit_type;
- }
-
FileSystemContext* file_system_context_;
scoped_refptr<base::SequencedTaskRunner> task_runner_;
@@ -116,6 +116,9 @@ class WEBKIT_STORAGE_EXPORT_PRIVATE FileSystemOperationContext
ChangeObserverList change_observers_;
UpdateObserverList update_observers_;
+ // Used to check its setters are not called on arbitrary thread.
+ base::ThreadChecker setter_thread_checker_;
+
DISALLOW_COPY_AND_ASSIGN(FileSystemOperationContext);
};
« no previous file with comments | « no previous file | webkit/fileapi/file_system_operation_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698