OLD | NEW |
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_LOCAL_LOCAL_FILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_SERVICE_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_SERVICE_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <set> | 11 #include <set> |
10 #include <string> | 12 #include <string> |
11 | 13 |
12 #include "base/basictypes.h" | |
13 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
17 #include "chrome/browser/sync_file_system/local/local_origin_change_observer.h" | 19 #include "chrome/browser/sync_file_system/local/local_origin_change_observer.h" |
18 #include "chrome/browser/sync_file_system/remote_change_processor.h" | 20 #include "chrome/browser/sync_file_system/remote_change_processor.h" |
19 #include "chrome/browser/sync_file_system/sync_callbacks.h" | 21 #include "chrome/browser/sync_file_system/sync_callbacks.h" |
20 #include "chrome/browser/sync_file_system/sync_status_code.h" | 22 #include "chrome/browser/sync_file_system/sync_status_code.h" |
21 | 23 |
22 class GURL; | 24 class GURL; |
23 class Profile; | 25 class Profile; |
(...skipping 29 matching lines...) Expand all Loading... |
53 | 55 |
54 class Observer { | 56 class Observer { |
55 public: | 57 public: |
56 Observer() {} | 58 Observer() {} |
57 virtual ~Observer() {} | 59 virtual ~Observer() {} |
58 | 60 |
59 // This is called when there're one or more local changes available. | 61 // This is called when there're one or more local changes available. |
60 // |pending_changes_hint| indicates the pending queue length to help sync | 62 // |pending_changes_hint| indicates the pending queue length to help sync |
61 // scheduling but the value may not be accurately reflect the real-time | 63 // scheduling but the value may not be accurately reflect the real-time |
62 // value. | 64 // value. |
63 virtual void OnLocalChangeAvailable(int64 pending_changes_hint) = 0; | 65 virtual void OnLocalChangeAvailable(int64_t pending_changes_hint) = 0; |
64 | 66 |
65 private: | 67 private: |
66 DISALLOW_COPY_AND_ASSIGN(Observer); | 68 DISALLOW_COPY_AND_ASSIGN(Observer); |
67 }; | 69 }; |
68 | 70 |
69 typedef base::Callback<void(SyncStatusCode status, | 71 typedef base::Callback<void(SyncStatusCode status, |
70 bool has_pending_changes)> | 72 bool has_pending_changes)> |
71 HasPendingLocalChangeCallback; | 73 HasPendingLocalChangeCallback; |
72 | 74 |
73 static scoped_ptr<LocalFileSyncService> Create(Profile* profile); | 75 static scoped_ptr<LocalFileSyncService> Create(Profile* profile); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // the service is running. This may be called for origins/apps that | 152 // the service is running. This may be called for origins/apps that |
151 // are not initialized for the service. | 153 // are not initialized for the service. |
152 void SetOriginEnabled(const GURL& origin, bool enabled); | 154 void SetOriginEnabled(const GURL& origin, bool enabled); |
153 | 155 |
154 private: | 156 private: |
155 typedef std::map<GURL, storage::FileSystemContext*> OriginToContext; | 157 typedef std::map<GURL, storage::FileSystemContext*> OriginToContext; |
156 friend class OriginChangeMapTest; | 158 friend class OriginChangeMapTest; |
157 | 159 |
158 class OriginChangeMap { | 160 class OriginChangeMap { |
159 public: | 161 public: |
160 typedef std::map<GURL, int64> Map; | 162 typedef std::map<GURL, int64_t> Map; |
161 | 163 |
162 OriginChangeMap(); | 164 OriginChangeMap(); |
163 ~OriginChangeMap(); | 165 ~OriginChangeMap(); |
164 | 166 |
165 // Sets |origin| to the next origin to process. (For now we simply apply | 167 // Sets |origin| to the next origin to process. (For now we simply apply |
166 // round-robin to pick the next origin to avoid starvation.) | 168 // round-robin to pick the next origin to avoid starvation.) |
167 // Returns false if no origins to process. | 169 // Returns false if no origins to process. |
168 bool NextOriginToProcess(GURL* origin); | 170 bool NextOriginToProcess(GURL* origin); |
169 | 171 |
170 int64 GetTotalChangeCount() const; | 172 int64_t GetTotalChangeCount() const; |
171 | 173 |
172 // Update change_count_map_ for |origin|. | 174 // Update change_count_map_ for |origin|. |
173 void SetOriginChangeCount(const GURL& origin, int64 changes); | 175 void SetOriginChangeCount(const GURL& origin, int64_t changes); |
174 | 176 |
175 void SetOriginEnabled(const GURL& origin, bool enabled); | 177 void SetOriginEnabled(const GURL& origin, bool enabled); |
176 | 178 |
177 private: | 179 private: |
178 // Per-origin changes (cached info, could be stale). | 180 // Per-origin changes (cached info, could be stale). |
179 Map change_count_map_; | 181 Map change_count_map_; |
180 Map::iterator next_; | 182 Map::iterator next_; |
181 | 183 |
182 // Holds a set of disabled (but initialized) origins. | 184 // Holds a set of disabled (but initialized) origins. |
183 std::set<GURL> disabled_origins_; | 185 std::set<GURL> disabled_origins_; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 GetLocalChangeProcessorCallback get_local_change_processor_; | 238 GetLocalChangeProcessorCallback get_local_change_processor_; |
237 | 239 |
238 base::ObserverList<Observer> change_observers_; | 240 base::ObserverList<Observer> change_observers_; |
239 | 241 |
240 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncService); | 242 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncService); |
241 }; | 243 }; |
242 | 244 |
243 } // namespace sync_file_system | 245 } // namespace sync_file_system |
244 | 246 |
245 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_SERVICE_H_ | 247 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_SERVICE_H_ |
OLD | NEW |