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

Side by Side Diff: webkit/fileapi/syncable/local_file_sync_context.h

Issue 11238054: Add OnSyncEnabled/OnWriteEnabled notification handling to operation runner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added export 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
« no previous file with comments | « no previous file | webkit/fileapi/syncable/local_file_sync_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SYNCABLE_LOCAL_FILE_SYNC_CONTEXT_H_ 5 #ifndef WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_SYNC_CONTEXT_H_
6 #define WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_SYNC_CONTEXT_H_ 6 #define WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_SYNC_CONTEXT_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
20 #include "webkit/fileapi/syncable/file_change.h" 20 #include "webkit/fileapi/syncable/file_change.h"
21 #include "webkit/fileapi/syncable/local_file_sync_status.h"
21 #include "webkit/fileapi/syncable/sync_status_code.h" 22 #include "webkit/fileapi/syncable/sync_status_code.h"
22 #include "webkit/storage/webkit_storage_export.h" 23 #include "webkit/storage/webkit_storage_export.h"
23 24
24 namespace base { 25 namespace base {
25 class SingleThreadTaskRunner; 26 class SingleThreadTaskRunner;
26 } 27 }
27 28
28 namespace fileapi { 29 namespace fileapi {
29 30
31 class FileChange;
30 class FileSystemContext; 32 class FileSystemContext;
31 class LocalFileChangeTracker; 33 class LocalFileChangeTracker;
32 class SyncableFileOperationRunner; 34 class SyncableFileOperationRunner;
33 35
34 // This class works as a bridge between LocalFileSyncService (which is a 36 // This class works as a bridge between LocalFileSyncService (which is a
35 // per-profile object) and FileSystemContext's (which is a per-storage-partition 37 // per-profile object) and FileSystemContext's (which is a per-storage-partition
36 // object and may exist multiple in a profile). 38 // object and may exist multiple in a profile).
37 // An instance of this class is shared by FileSystemContexts and outlives 39 // An instance of this class is shared by FileSystemContexts and outlives
38 // LocalFileSyncService. 40 // LocalFileSyncService.
39 class WEBKIT_STORAGE_EXPORT LocalFileSyncContext 41 class WEBKIT_STORAGE_EXPORT LocalFileSyncContext
(...skipping 12 matching lines...) Expand all
52 FileSystemContext* file_system_context, 54 FileSystemContext* file_system_context,
53 const StatusCallback& callback); 55 const StatusCallback& callback);
54 56
55 // Called when the corresponding LocalFileSyncService exits. 57 // Called when the corresponding LocalFileSyncService exits.
56 // This method must be called on UI thread. 58 // This method must be called on UI thread.
57 void ShutdownOnUIThread(); 59 void ShutdownOnUIThread();
58 60
59 // OperationRunner is accessible only on IO thread. 61 // OperationRunner is accessible only on IO thread.
60 base::WeakPtr<SyncableFileOperationRunner> operation_runner() const; 62 base::WeakPtr<SyncableFileOperationRunner> operation_runner() const;
61 63
64 // SyncContext is accessible only on IO thread.
65 LocalFileSyncStatus* sync_status() const;
66
62 private: 67 private:
63 typedef std::deque<StatusCallback> StatusCallbackQueue; 68 typedef std::deque<StatusCallback> StatusCallbackQueue;
64 friend class base::RefCountedThreadSafe<LocalFileSyncContext>; 69 friend class base::RefCountedThreadSafe<LocalFileSyncContext>;
65 friend class CannedSyncableFileSystem; 70 friend class CannedSyncableFileSystem;
66 71
67 ~LocalFileSyncContext(); 72 virtual ~LocalFileSyncContext();
68 73
69 void ShutdownOnIOThread(); 74 void ShutdownOnIOThread();
70 75
71 // Helper routines for MaybeInitializeFileSystemContext. 76 // Helper routines for MaybeInitializeFileSystemContext.
72 void InitializeFileSystemContextOnIOThread( 77 void InitializeFileSystemContextOnIOThread(
73 const GURL& source_url, 78 const GURL& source_url,
74 FileSystemContext* file_system_context); 79 FileSystemContext* file_system_context);
75 SyncStatusCode InitializeChangeTrackerOnFileThread( 80 SyncStatusCode InitializeChangeTrackerOnFileThread(
76 scoped_ptr<LocalFileChangeTracker>* tracker_ptr, 81 scoped_ptr<LocalFileChangeTracker>* tracker_ptr,
77 FileSystemContext* file_system_context); 82 FileSystemContext* file_system_context);
78 void DidInitializeChangeTracker( 83 void DidInitializeChangeTracker(
79 scoped_ptr<LocalFileChangeTracker>* tracker_ptr, 84 scoped_ptr<LocalFileChangeTracker>* tracker_ptr,
80 const GURL& source_url, 85 const GURL& source_url,
81 FileSystemContext* file_system_context, 86 FileSystemContext* file_system_context,
82 SyncStatusCode status); 87 SyncStatusCode status);
83 void DidInitialize( 88 void DidInitialize(
84 const GURL& source_url, 89 const GURL& source_url,
85 FileSystemContext* file_system_context, 90 FileSystemContext* file_system_context,
86 SyncStatusCode status); 91 SyncStatusCode status);
87 92
88 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 93 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
89 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 94 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
90 95
91 // OperationRunner. This must be accessed only on IO thread. 96 // OperationRunner. This must be accessed only on IO thread.
92 scoped_ptr<SyncableFileOperationRunner> operation_runner_; 97 scoped_ptr<SyncableFileOperationRunner> operation_runner_;
93 98
99 // Keeps track of writing/syncing status.
100 // This must be accessed only on IO thread.
101 scoped_ptr<LocalFileSyncStatus> sync_status_;
102
94 // Pointers to file system contexts that have been initialized for 103 // Pointers to file system contexts that have been initialized for
95 // synchronization (i.e. that own this instance). 104 // synchronization (i.e. that own this instance).
96 // This must be accessed only on UI thread. 105 // This must be accessed only on UI thread.
97 std::set<FileSystemContext*> file_system_contexts_; 106 std::set<FileSystemContext*> file_system_contexts_;
98 107
108 // Accessed only on UI thread.
99 std::map<FileSystemContext*, StatusCallbackQueue> 109 std::map<FileSystemContext*, StatusCallbackQueue>
100 pending_initialize_callbacks_; 110 pending_initialize_callbacks_;
101 111
102 // Origin to context map. (Assuming that as far as we're in the same 112 // Origin to context map. (Assuming that as far as we're in the same
103 // profile single origin wouldn't belong to multiple FileSystemContexts.) 113 // profile single origin wouldn't belong to multiple FileSystemContexts.)
114 // Accessed only on UI thread.
104 std::map<GURL, FileSystemContext*> origin_to_contexts_; 115 std::map<GURL, FileSystemContext*> origin_to_contexts_;
105 116
106 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncContext); 117 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncContext);
107 }; 118 };
108 119
109 } // namespace fileapi 120 } // namespace fileapi
110 121
111 #endif // WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_SYNC_CONTEXT_H_ 122 #endif // WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_SYNC_CONTEXT_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/fileapi/syncable/local_file_sync_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698