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 CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "chrome/browser/chromeos/drive/file_errors.h" | 16 #include "chrome/browser/chromeos/drive/file_errors.h" |
| 17 #include "google_apis/drive/drive_api_error_codes.h" |
17 #include "google_apis/drive/drive_common_callbacks.h" | 18 #include "google_apis/drive/drive_common_callbacks.h" |
18 #include "google_apis/drive/gdata_errorcode.h" | |
19 | 19 |
20 class GURL; | 20 class GURL; |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class ScopedClosureRunner; | 23 class ScopedClosureRunner; |
24 class SequencedTaskRunner; | 24 class SequencedTaskRunner; |
25 class Time; | 25 class Time; |
26 } // namespace base | 26 } // namespace base |
27 | 27 |
28 namespace google_apis { | 28 namespace google_apis { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // used in |GetAboutResource|. | 96 // used in |GetAboutResource|. |
97 void UpdateAboutResource(const google_apis::AboutResourceCallback& callback); | 97 void UpdateAboutResource(const google_apis::AboutResourceCallback& callback); |
98 | 98 |
99 private: | 99 private: |
100 // Part of UpdateAboutResource(). | 100 // Part of UpdateAboutResource(). |
101 // This function should be called when the latest about resource is being | 101 // This function should be called when the latest about resource is being |
102 // fetched from the server. The retrieved about resource is cloned, and one is | 102 // fetched from the server. The retrieved about resource is cloned, and one is |
103 // cached and the other is passed to callbacks associated with |task_id|. | 103 // cached and the other is passed to callbacks associated with |task_id|. |
104 void UpdateAboutResourceAfterGetAbout( | 104 void UpdateAboutResourceAfterGetAbout( |
105 int task_id, | 105 int task_id, |
106 google_apis::GDataErrorCode status, | 106 google_apis::DriveApiErrorCode status, |
107 scoped_ptr<google_apis::AboutResource> about_resource); | 107 scoped_ptr<google_apis::AboutResource> about_resource); |
108 | 108 |
109 JobScheduler* scheduler_; | 109 JobScheduler* scheduler_; |
110 scoped_ptr<google_apis::AboutResource> cached_about_resource_; | 110 scoped_ptr<google_apis::AboutResource> cached_about_resource_; |
111 | 111 |
112 // Identifier to denote the latest UpdateAboutResource call. | 112 // Identifier to denote the latest UpdateAboutResource call. |
113 int current_update_task_id_; | 113 int current_update_task_id_; |
114 // Mapping from each UpdateAboutResource task ID to the corresponding | 114 // Mapping from each UpdateAboutResource task ID to the corresponding |
115 // callbacks. Note that there will be multiple callbacks for a single task | 115 // callbacks. Note that there will be multiple callbacks for a single task |
116 // when GetAboutResource is called before the task completes. | 116 // when GetAboutResource is called before the task completes. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 void LoadIfNeeded(const FileOperationCallback& callback); | 168 void LoadIfNeeded(const FileOperationCallback& callback); |
169 | 169 |
170 private: | 170 private: |
171 // Starts the resource metadata loading and calls |callback| when it's done. | 171 // Starts the resource metadata loading and calls |callback| when it's done. |
172 void Load(const FileOperationCallback& callback); | 172 void Load(const FileOperationCallback& callback); |
173 void LoadAfterGetLargestChangestamp(bool is_initial_load, | 173 void LoadAfterGetLargestChangestamp(bool is_initial_load, |
174 const int64* local_changestamp, | 174 const int64* local_changestamp, |
175 FileError error); | 175 FileError error); |
176 void LoadAfterGetAboutResource( | 176 void LoadAfterGetAboutResource( |
177 int64 local_changestamp, | 177 int64 local_changestamp, |
178 google_apis::GDataErrorCode status, | 178 google_apis::DriveApiErrorCode status, |
179 scoped_ptr<google_apis::AboutResource> about_resource); | 179 scoped_ptr<google_apis::AboutResource> about_resource); |
180 | 180 |
181 // Part of Load(). | 181 // Part of Load(). |
182 // This function should be called when the change list load is complete. | 182 // This function should be called when the change list load is complete. |
183 // Flushes the callbacks for change list loading and all directory loading. | 183 // Flushes the callbacks for change list loading and all directory loading. |
184 void OnChangeListLoadComplete(FileError error); | 184 void OnChangeListLoadComplete(FileError error); |
185 | 185 |
186 // Called when the loading about_resource_loader_->UpdateAboutResource is | 186 // Called when the loading about_resource_loader_->UpdateAboutResource is |
187 // completed. | 187 // completed. |
188 void OnAboutResourceUpdated(google_apis::GDataErrorCode error, | 188 void OnAboutResourceUpdated(google_apis::DriveApiErrorCode error, |
189 scoped_ptr<google_apis::AboutResource> resource); | 189 scoped_ptr<google_apis::AboutResource> resource); |
190 | 190 |
191 // ================= Implementation for change list loading ================= | 191 // ================= Implementation for change list loading ================= |
192 | 192 |
193 // Part of LoadFromServerIfNeeded(). | 193 // Part of LoadFromServerIfNeeded(). |
194 // Starts loading the change list since |start_changestamp|, or the full | 194 // Starts loading the change list since |start_changestamp|, or the full |
195 // resource list if |start_changestamp| is zero. | 195 // resource list if |start_changestamp| is zero. |
196 void LoadChangeListFromServer(int64 start_changestamp); | 196 void LoadChangeListFromServer(int64 start_changestamp); |
197 | 197 |
198 // Part of LoadChangeListFromServer(). | 198 // Part of LoadChangeListFromServer(). |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // Note: This should remain the last member so it'll be destroyed and | 231 // Note: This should remain the last member so it'll be destroyed and |
232 // invalidate its weak pointers before any other members are destroyed. | 232 // invalidate its weak pointers before any other members are destroyed. |
233 base::WeakPtrFactory<ChangeListLoader> weak_ptr_factory_; | 233 base::WeakPtrFactory<ChangeListLoader> weak_ptr_factory_; |
234 DISALLOW_COPY_AND_ASSIGN(ChangeListLoader); | 234 DISALLOW_COPY_AND_ASSIGN(ChangeListLoader); |
235 }; | 235 }; |
236 | 236 |
237 } // namespace internal | 237 } // namespace internal |
238 } // namespace drive | 238 } // namespace drive |
239 | 239 |
240 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ | 240 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ |
OLD | NEW |