Chromium Code Reviews| 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_GDATA_GDATA_WAPI_FEED_LOADER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h" | 11 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h" |
| 12 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | 12 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" |
| 13 | 13 #include "googleurl/src/gurl.h" |
| 14 class GURL; | |
| 15 | 14 |
| 16 namespace base { | 15 namespace base { |
| 17 class Value; | 16 class Value; |
| 18 } | 17 } |
| 19 | 18 |
| 20 namespace gdata { | 19 namespace gdata { |
| 21 | 20 |
| 22 class DriveWebAppsRegistryInterface; | 21 class DriveWebAppsRegistryInterface; |
| 23 class DocumentFeed; | 22 class DocumentFeed; |
| 24 class DocumentsServiceInterface; | 23 class DocumentsServiceInterface; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 // Time when filesystem began to be loaded from disk. | 66 // Time when filesystem began to be loaded from disk. |
| 68 base::Time load_start_time; | 67 base::Time load_start_time; |
| 69 const FileOperationCallback callback; | 68 const FileOperationCallback callback; |
| 70 }; | 69 }; |
| 71 | 70 |
| 72 // Callback run as a response to LoadFromServer. | 71 // Callback run as a response to LoadFromServer. |
| 73 typedef base::Callback<void(GetDocumentsParams* params, | 72 typedef base::Callback<void(GetDocumentsParams* params, |
| 74 GDataFileError error)> | 73 GDataFileError error)> |
| 75 LoadDocumentFeedCallback; | 74 LoadDocumentFeedCallback; |
| 76 | 75 |
| 76 // Defines set of parameters for calling GDataWapiFeedLoader::LoadFromServer(). | |
| 77 // Value of |start_changestamp| determines the type of feed to load - 0 means | |
| 78 // root feed, every other value would trigger delta feed. | |
| 79 // In the case of loading the root feed we use |root_feed_changestamp| as its | |
| 80 // initial changestamp value since it does not come with that info. | |
| 81 // | |
| 82 // When all feeds are loaded, |feed_load_callback| is invoked with the retrieved | |
| 83 // feeds. Then |load_finished_callback| is invoked with the error code. | |
| 84 // | |
| 85 // |should_fetch_multiple_feeds| is true iff don't want to stop feed loading | |
| 86 // after we retrieve first feed chunk. | |
| 87 // If invoked as a part of content search, query will be set in |search_query|. | |
| 88 // If |feed_to_load| is set, this is feed url that will be used to load feed. | |
| 89 // | |
| 90 // |load_finished_callback| may be null. | |
| 91 // |feed_load_callback| must not be null. | |
| 92 struct LoadFeedParams { | |
| 93 LoadFeedParams(ContentOrigin initial_origin, | |
| 94 const LoadDocumentFeedCallback& feed_load_callback); | |
| 95 ~LoadFeedParams(); | |
| 96 | |
| 97 ContentOrigin initial_origin; | |
| 98 int64 start_changestamp; | |
| 99 int64 root_feed_changestamp; | |
| 100 bool should_fetch_multiple_feeds; | |
| 101 FilePath search_file_path; | |
| 102 std::string search_query; | |
| 103 GURL feed_to_load; | |
| 104 std::string directory_resource_id; | |
| 105 FileOperationCallback load_finished_callback; | |
| 106 const LoadDocumentFeedCallback feed_load_callback; | |
| 107 }; | |
|
satorux1
2012/08/16 10:56:29
hmm, rather than just putting a bunch of parameter
| |
| 108 | |
| 77 // GDataWapiFeedLoader is used to load feeds from WAPI (codename for | 109 // GDataWapiFeedLoader is used to load feeds from WAPI (codename for |
| 78 // Documents List API) and load the cached proto file. | 110 // Documents List API) and load the cached proto file. |
| 79 class GDataWapiFeedLoader { | 111 class GDataWapiFeedLoader { |
| 80 public: | 112 public: |
| 81 // Used to notify events from the loader. | 113 // Used to notify events from the loader. |
| 82 // All events are notified on UI thread. | 114 // All events are notified on UI thread. |
| 83 class Observer { | 115 class Observer { |
| 84 public: | 116 public: |
| 85 // Triggered when a content of a directory has been changed. | 117 // Triggered when a content of a directory has been changed. |
| 86 // |directory_path| is a virtual directory path representing the | 118 // |directory_path| is a virtual directory path representing the |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 116 // Then, it will initiate retrieval of the root feed from the server unless | 148 // Then, it will initiate retrieval of the root feed from the server unless |
| 117 // |should_load_from_server| is set to false. |should_load_from_server| is | 149 // |should_load_from_server| is set to false. |should_load_from_server| is |
| 118 // false only for testing. If loading from the server is successful, runs | 150 // false only for testing. If loading from the server is successful, runs |
| 119 // |callback| if it was not previously run (i.e. loading from the cache was | 151 // |callback| if it was not previously run (i.e. loading from the cache was |
| 120 // successful). | 152 // successful). |
| 121 // | 153 // |
| 122 // |callback| may be null. | 154 // |callback| may be null. |
| 123 void LoadFromCache(bool should_load_from_server, | 155 void LoadFromCache(bool should_load_from_server, |
| 124 const FileOperationCallback& callback); | 156 const FileOperationCallback& callback); |
| 125 | 157 |
| 126 // Starts root feed load from the server. Value of |start_changestamp| | 158 // Starts root feed load from the server, with detail specified in |param|. |
| 127 // determines the type of feed to load - 0 means root feed, every other | 159 void LoadFromServer(const LoadFeedParams& param); |
| 128 // value would trigger delta feed. | |
| 129 // In the case of loading the root feed we use |root_feed_changestamp| as its | |
| 130 // initial changestamp value since it does not come with that info. | |
| 131 // | |
| 132 // When all feeds are loaded, |feed_load_callback| is invoked with the | |
| 133 // retrieved feeds. Then |load_finished_callback| is invoked with the error | |
| 134 // code. | |
| 135 // | |
| 136 // |should_fetch_multiple_feeds| is true iff don't want to stop feed loading | |
| 137 // after we retrieve first feed chunk. | |
| 138 // If invoked as a part of content search, query will be set in | |
| 139 // |search_query|. | |
| 140 // If |feed_to_load| is set, this is feed url that will be used to load feed. | |
| 141 // | |
| 142 // |load_finished_callback| may be null. | |
| 143 // |feed_load_callback| must not be null. | |
| 144 void LoadFromServer( | |
| 145 ContentOrigin initial_origin, | |
| 146 int64 start_changestamp, | |
| 147 int64 root_feed_changestamp, | |
| 148 bool should_fetch_multiple_feeds, | |
| 149 const std::string& search_query, | |
| 150 const GURL& feed_to_load, | |
| 151 const std::string& directory_resource_id, | |
| 152 const FileOperationCallback& load_finished_callback, | |
| 153 const LoadDocumentFeedCallback& feed_load_callback); | |
| 154 | 160 |
| 155 // Retrieves account metadata and determines from the last change timestamp | 161 // Retrieves account metadata and determines from the last change timestamp |
| 156 // if the feed content loading from the server needs to be initiated. | 162 // if the feed content loading from the server needs to be initiated. |
| 157 void ReloadFromServerIfNeeded( | 163 void ReloadFromServerIfNeeded( |
| 158 ContentOrigin initial_origin, | 164 ContentOrigin initial_origin, |
| 159 int64 local_changestamp, | 165 int64 local_changestamp, |
| 160 const FileOperationCallback& callback); | 166 const FileOperationCallback& callback); |
| 161 | 167 |
| 162 // Updates whole directory structure feeds collected in |feed_list|. | 168 // Updates whole directory structure feeds collected in |feed_list|. |
| 163 // On success, returns PLATFORM_FILE_OK. Record file statistics as UMA | 169 // On success, returns PLATFORM_FILE_OK. Record file statistics as UMA |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 | 258 |
| 253 // Note: This should remain the last member so it'll be destroyed and | 259 // Note: This should remain the last member so it'll be destroyed and |
| 254 // invalidate its weak pointers before any other members are destroyed. | 260 // invalidate its weak pointers before any other members are destroyed. |
| 255 base::WeakPtrFactory<GDataWapiFeedLoader> weak_ptr_factory_; | 261 base::WeakPtrFactory<GDataWapiFeedLoader> weak_ptr_factory_; |
| 256 DISALLOW_COPY_AND_ASSIGN(GDataWapiFeedLoader); | 262 DISALLOW_COPY_AND_ASSIGN(GDataWapiFeedLoader); |
| 257 }; | 263 }; |
| 258 | 264 |
| 259 } // namespace gdata | 265 } // namespace gdata |
| 260 | 266 |
| 261 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_ | 267 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_ |
| OLD | NEW |