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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend_v1/remote_change_handler.h

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_CHANGE_HANDLER_H _ 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_CHANGE_HANDLER_H _
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_CHANGE_HANDLER_H _ 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_CHANGE_HANDLER_H _
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "chrome/browser/sync_file_system/file_change.h" 16 #include "chrome/browser/sync_file_system/file_change.h"
17 #include "webkit/browser/fileapi/file_system_url.h" 17 #include "storage/browser/fileapi/file_system_url.h"
18 18
19 namespace sync_file_system { 19 namespace sync_file_system {
20 20
21 // Manages pending remote file changes. 21 // Manages pending remote file changes.
22 class RemoteChangeHandler { 22 class RemoteChangeHandler {
23 public: 23 public:
24 struct RemoteChange { 24 struct RemoteChange {
25 int64 changestamp; 25 int64 changestamp;
26 std::string resource_id; 26 std::string resource_id;
27 std::string md5_checksum; 27 std::string md5_checksum;
28 base::Time updated_time; 28 base::Time updated_time;
29 fileapi::FileSystemURL url; 29 storage::FileSystemURL url;
30 FileChange change; 30 FileChange change;
31 31
32 RemoteChange(); 32 RemoteChange();
33 RemoteChange(int64 changestamp, 33 RemoteChange(int64 changestamp,
34 const std::string& resource_id, 34 const std::string& resource_id,
35 const std::string& md5_checksum, 35 const std::string& md5_checksum,
36 const base::Time& updated_time, 36 const base::Time& updated_time,
37 const fileapi::FileSystemURL& url, 37 const storage::FileSystemURL& url,
38 const FileChange& change); 38 const FileChange& change);
39 ~RemoteChange(); 39 ~RemoteChange();
40 }; 40 };
41 41
42 struct RemoteChangeComparator { 42 struct RemoteChangeComparator {
43 bool operator()(const RemoteChange& left, const RemoteChange& right); 43 bool operator()(const RemoteChange& left, const RemoteChange& right);
44 }; 44 };
45 45
46 RemoteChangeHandler(); 46 RemoteChangeHandler();
47 virtual ~RemoteChangeHandler(); 47 virtual ~RemoteChangeHandler();
48 48
49 // Pushes the next change into |remote_change| and returns true. 49 // Pushes the next change into |remote_change| and returns true.
50 bool GetChange(RemoteChange* remote_change); 50 bool GetChange(RemoteChange* remote_change);
51 51
52 // Pushes the change for the |url| into |remote_change| and returns true. 52 // Pushes the change for the |url| into |remote_change| and returns true.
53 bool GetChangeForURL(const fileapi::FileSystemURL& url, 53 bool GetChangeForURL(const storage::FileSystemURL& url,
54 RemoteChange* remote_change); 54 RemoteChange* remote_change);
55 55
56 // Appends |remote_change| into the change queue. |remote_change| overrides an 56 // Appends |remote_change| into the change queue. |remote_change| overrides an
57 // existing change for the same URL if exists. 57 // existing change for the same URL if exists.
58 void AppendChange(const RemoteChange& remote_change); 58 void AppendChange(const RemoteChange& remote_change);
59 59
60 // Removes a change for the |url|. 60 // Removes a change for the |url|.
61 bool RemoveChangeForURL(const fileapi::FileSystemURL& url); 61 bool RemoveChangeForURL(const storage::FileSystemURL& url);
62 62
63 // Removes changes for the |origin|. 63 // Removes changes for the |origin|.
64 void RemoveChangesForOrigin(const GURL& origin); 64 void RemoveChangesForOrigin(const GURL& origin);
65 65
66 bool HasChangesForOrigin(const GURL& origin) const; 66 bool HasChangesForOrigin(const GURL& origin) const;
67 bool HasChanges() const { return !changes_.empty(); } 67 bool HasChanges() const { return !changes_.empty(); }
68 size_t ChangesSize() const { return changes_.size(); } 68 size_t ChangesSize() const { return changes_.size(); }
69 69
70 private: 70 private:
71 struct ChangeQueueItem { 71 struct ChangeQueueItem {
72 int64 changestamp; 72 int64 changestamp;
73 fileapi::FileSystemURL url; 73 storage::FileSystemURL url;
74 74
75 ChangeQueueItem(); 75 ChangeQueueItem();
76 ChangeQueueItem(int64 changestamp, 76 ChangeQueueItem(int64 changestamp, const storage::FileSystemURL& url);
77 const fileapi::FileSystemURL& url);
78 }; 77 };
79 78
80 struct ChangeQueueComparator { 79 struct ChangeQueueComparator {
81 bool operator()(const ChangeQueueItem& left, const ChangeQueueItem& right); 80 bool operator()(const ChangeQueueItem& left, const ChangeQueueItem& right);
82 }; 81 };
83 82
84 typedef std::set<ChangeQueueItem, ChangeQueueComparator> PendingChangeQueue; 83 typedef std::set<ChangeQueueItem, ChangeQueueComparator> PendingChangeQueue;
85 84
86 struct ChangeMapItem { 85 struct ChangeMapItem {
87 RemoteChange remote_change; 86 RemoteChange remote_change;
(...skipping 12 matching lines...) Expand all
100 99
101 PendingChangeQueue changes_; 100 PendingChangeQueue changes_;
102 OriginToChangesMap origin_to_changes_map_; 101 OriginToChangesMap origin_to_changes_map_;
103 102
104 DISALLOW_COPY_AND_ASSIGN(RemoteChangeHandler); 103 DISALLOW_COPY_AND_ASSIGN(RemoteChangeHandler);
105 }; 104 };
106 105
107 } // namespace sync_file_system 106 } // namespace sync_file_system
108 107
109 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_CHANGE_HANDLE R_H_ 108 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_CHANGE_HANDLE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698