| 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 COMPONENTS_DRIVE_CHANGE_LIST_LOADER_H_ | 5 #ifndef COMPONENTS_DRIVE_CHANGE_LIST_LOADER_H_ |
| 6 #define COMPONENTS_DRIVE_CHANGE_LIST_LOADER_H_ | 6 #define COMPONENTS_DRIVE_CHANGE_LIST_LOADER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 #include <vector> | 11 #include <vector> |
| 10 | 12 |
| 11 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
| 15 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
| 16 #include "base/threading/thread_checker.h" | 19 #include "base/threading/thread_checker.h" |
| 17 #include "components/drive/file_errors.h" | 20 #include "components/drive/file_errors.h" |
| 18 #include "google_apis/drive/drive_api_error_codes.h" | 21 #include "google_apis/drive/drive_api_error_codes.h" |
| 19 #include "google_apis/drive/drive_common_callbacks.h" | 22 #include "google_apis/drive/drive_common_callbacks.h" |
| 20 | 23 |
| 21 class GURL; | 24 class GURL; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // starts loading from the server, and runs |callback| to tell the result to | 173 // starts loading from the server, and runs |callback| to tell the result to |
| 171 // the caller when it is finished. | 174 // the caller when it is finished. |
| 172 // | 175 // |
| 173 // |callback| must not be null. | 176 // |callback| must not be null. |
| 174 void LoadIfNeeded(const FileOperationCallback& callback); | 177 void LoadIfNeeded(const FileOperationCallback& callback); |
| 175 | 178 |
| 176 private: | 179 private: |
| 177 // Starts the resource metadata loading and calls |callback| when it's done. | 180 // Starts the resource metadata loading and calls |callback| when it's done. |
| 178 void Load(const FileOperationCallback& callback); | 181 void Load(const FileOperationCallback& callback); |
| 179 void LoadAfterGetLargestChangestamp(bool is_initial_load, | 182 void LoadAfterGetLargestChangestamp(bool is_initial_load, |
| 180 const int64* local_changestamp, | 183 const int64_t* local_changestamp, |
| 181 FileError error); | 184 FileError error); |
| 182 void LoadAfterGetAboutResource( | 185 void LoadAfterGetAboutResource( |
| 183 int64 local_changestamp, | 186 int64_t local_changestamp, |
| 184 google_apis::DriveApiErrorCode status, | 187 google_apis::DriveApiErrorCode status, |
| 185 scoped_ptr<google_apis::AboutResource> about_resource); | 188 scoped_ptr<google_apis::AboutResource> about_resource); |
| 186 | 189 |
| 187 // Part of Load(). | 190 // Part of Load(). |
| 188 // This function should be called when the change list load is complete. | 191 // This function should be called when the change list load is complete. |
| 189 // Flushes the callbacks for change list loading and all directory loading. | 192 // Flushes the callbacks for change list loading and all directory loading. |
| 190 void OnChangeListLoadComplete(FileError error); | 193 void OnChangeListLoadComplete(FileError error); |
| 191 | 194 |
| 192 // Called when the loading about_resource_loader_->UpdateAboutResource is | 195 // Called when the loading about_resource_loader_->UpdateAboutResource is |
| 193 // completed. | 196 // completed. |
| 194 void OnAboutResourceUpdated(google_apis::DriveApiErrorCode error, | 197 void OnAboutResourceUpdated(google_apis::DriveApiErrorCode error, |
| 195 scoped_ptr<google_apis::AboutResource> resource); | 198 scoped_ptr<google_apis::AboutResource> resource); |
| 196 | 199 |
| 197 // ================= Implementation for change list loading ================= | 200 // ================= Implementation for change list loading ================= |
| 198 | 201 |
| 199 // Part of LoadFromServerIfNeeded(). | 202 // Part of LoadFromServerIfNeeded(). |
| 200 // Starts loading the change list since |start_changestamp|, or the full | 203 // Starts loading the change list since |start_changestamp|, or the full |
| 201 // resource list if |start_changestamp| is zero. | 204 // resource list if |start_changestamp| is zero. |
| 202 void LoadChangeListFromServer(int64 start_changestamp); | 205 void LoadChangeListFromServer(int64_t start_changestamp); |
| 203 | 206 |
| 204 // Part of LoadChangeListFromServer(). | 207 // Part of LoadChangeListFromServer(). |
| 205 // Called when the entire change list is loaded. | 208 // Called when the entire change list is loaded. |
| 206 void LoadChangeListFromServerAfterLoadChangeList( | 209 void LoadChangeListFromServerAfterLoadChangeList( |
| 207 scoped_ptr<google_apis::AboutResource> about_resource, | 210 scoped_ptr<google_apis::AboutResource> about_resource, |
| 208 bool is_delta_update, | 211 bool is_delta_update, |
| 209 FileError error, | 212 FileError error, |
| 210 ScopedVector<ChangeList> change_lists); | 213 ScopedVector<ChangeList> change_lists); |
| 211 | 214 |
| 212 // Part of LoadChangeListFromServer(). | 215 // Part of LoadChangeListFromServer(). |
| (...skipping 27 matching lines...) Expand all Loading... |
| 240 // Note: This should remain the last member so it'll be destroyed and | 243 // Note: This should remain the last member so it'll be destroyed and |
| 241 // invalidate its weak pointers before any other members are destroyed. | 244 // invalidate its weak pointers before any other members are destroyed. |
| 242 base::WeakPtrFactory<ChangeListLoader> weak_ptr_factory_; | 245 base::WeakPtrFactory<ChangeListLoader> weak_ptr_factory_; |
| 243 DISALLOW_COPY_AND_ASSIGN(ChangeListLoader); | 246 DISALLOW_COPY_AND_ASSIGN(ChangeListLoader); |
| 244 }; | 247 }; |
| 245 | 248 |
| 246 } // namespace internal | 249 } // namespace internal |
| 247 } // namespace drive | 250 } // namespace drive |
| 248 | 251 |
| 249 #endif // COMPONENTS_DRIVE_CHANGE_LIST_LOADER_H_ | 252 #endif // COMPONENTS_DRIVE_CHANGE_LIST_LOADER_H_ |
| OLD | NEW |