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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h

Issue 10836285: Refactor GDataWapiFeedLoader::LoadFromServer() parameters (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update comments. Created 8 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 (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;
25 class GDataCache; 24 class GDataCache;
26 struct GetDocumentsUiState; 25 struct GetDocumentsUiState;
27 26
28 // Set of parameters sent to LoadDocumentFeedCallback callback. 27 // Set of parameters sent to LoadDocumentFeedCallback callback.
29 struct GetDocumentsParams { 28 struct GetDocumentsParams {
30 GetDocumentsParams(int64 start_changestamp, 29 GetDocumentsParams(int64 start_changestamp,
31 int64 root_feed_changestamp, 30 int64 root_feed_changestamp,
32 std::vector<DocumentFeed*>* feed_list, 31 std::vector<DocumentFeed*>* feed_list,
33 bool should_fetch_multiple_feeds,
34 const std::string& search_query, 32 const std::string& search_query,
35 const std::string& directory_resource_id, 33 const std::string& directory_resource_id,
36 const FileOperationCallback& callback, 34 const FileOperationCallback& callback,
37 GetDocumentsUiState* ui_state); 35 GetDocumentsUiState* ui_state);
38 ~GetDocumentsParams(); 36 ~GetDocumentsParams();
39 37
40 // Changestamps are positive numbers in increasing order. The difference 38 // Changestamps are positive numbers in increasing order. The difference
41 // between two changestamps is proportional equal to number of items in 39 // between two changestamps is proportional equal to number of items in
42 // delta feed between them - bigger the difference, more likely bigger 40 // delta feed between them - bigger the difference, more likely bigger
43 // number of items in delta feeds. 41 // number of items in delta feeds.
44 int64 start_changestamp; 42 int64 start_changestamp;
45 int64 root_feed_changestamp; 43 int64 root_feed_changestamp;
46 scoped_ptr<std::vector<DocumentFeed*> > feed_list; 44 scoped_ptr<std::vector<DocumentFeed*> > feed_list;
47 // Should we stop after getting first feed chunk, even if there is more
48 // data.
49 bool should_fetch_multiple_feeds;
50 std::string search_query; 45 std::string search_query;
51 std::string directory_resource_id; 46 std::string directory_resource_id;
52 FileOperationCallback callback; 47 FileOperationCallback callback;
53 scoped_ptr<GetDocumentsUiState> ui_state; 48 scoped_ptr<GetDocumentsUiState> ui_state;
54 }; 49 };
55 50
56 // Defines set of parameters sent to callback OnProtoLoaded(). 51 // Defines set of parameters sent to callback OnProtoLoaded().
57 struct LoadRootFeedParams { 52 struct LoadRootFeedParams {
58 LoadRootFeedParams( 53 LoadRootFeedParams(
59 bool should_load_from_server, 54 bool should_load_from_server,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // Then, it will initiate retrieval of the root feed from the server unless 111 // 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 112 // |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 113 // 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 114 // |callback| if it was not previously run (i.e. loading from the cache was
120 // successful). 115 // successful).
121 // 116 //
122 // |callback| may be null. 117 // |callback| may be null.
123 void LoadFromCache(bool should_load_from_server, 118 void LoadFromCache(bool should_load_from_server,
124 const FileOperationCallback& callback); 119 const FileOperationCallback& callback);
125 120
126 // Starts root feed load from the server. Value of |start_changestamp| 121 // Starts retrieving feed for a directory specified by |directory_resource_id|
127 // determines the type of feed to load - 0 means root feed, every other 122 // from the server. Upon completion, |feed_load_callback| is invoked.
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. 123 // |feed_load_callback| must not be null.
144 void LoadFromServer( 124 void LoadDirectoryFromServer(
145 ContentOrigin initial_origin, 125 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, 126 const std::string& directory_resource_id,
152 const FileOperationCallback& load_finished_callback,
153 const LoadDocumentFeedCallback& feed_load_callback); 127 const LoadDocumentFeedCallback& feed_load_callback);
154 128
129 // Starts retrieving search results for |search_query| from the server.
130 // If |next_feed| is set, this is the feed url that will be fetched.
131 // If |next_feed| is an empty string, the default URL is used.
132 // Upon completion, |feed_load_callback| is invoked. |feed_load_callback|
133 // must not be null.
satorux1 2012/08/17 16:00:12 nit: move the last sentence to a separate line. /
134 void SearchFromServer(ContentOrigin initial_origin,
135 const std::string& search_query,
136 const GURL& next_feed,
137 const LoadDocumentFeedCallback& feed_load_callback);
138
155 // Retrieves account metadata and determines from the last change timestamp 139 // Retrieves account metadata and determines from the last change timestamp
156 // if the feed content loading from the server needs to be initiated. 140 // if the feed content loading from the server needs to be initiated.
157 void ReloadFromServerIfNeeded( 141 void ReloadFromServerIfNeeded(
158 ContentOrigin initial_origin, 142 ContentOrigin initial_origin,
159 int64 local_changestamp, 143 int64 local_changestamp,
160 const FileOperationCallback& callback); 144 const FileOperationCallback& callback);
161 145
162 // Updates whole directory structure feeds collected in |feed_list|. 146 // Updates whole directory structure feeds collected in |feed_list|.
163 // On success, returns PLATFORM_FILE_OK. Record file statistics as UMA 147 // On success, returns PLATFORM_FILE_OK. Record file statistics as UMA
164 // histograms. 148 // histograms.
165 // 149 //
166 // See comments at GDataWapiFeedProcessor::ApplyFeeds() for 150 // See comments at GDataWapiFeedProcessor::ApplyFeeds() for
167 // |start_changestamp| and |root_feed_changestamp|. 151 // |start_changestamp| and |root_feed_changestamp|.
168 GDataFileError UpdateFromFeed( 152 GDataFileError UpdateFromFeed(
169 const std::vector<DocumentFeed*>& feed_list, 153 const std::vector<DocumentFeed*>& feed_list,
170 int64 start_changestamp, 154 int64 start_changestamp,
171 int64 root_feed_changestamp); 155 int64 root_feed_changestamp);
172 156
173 private: 157 private:
158 struct LoadFeedParams;
159
160 // Starts root feed load from the server, with detail specified in |param|.
161 void LoadFromServer(const LoadFeedParams& param);
162
174 // Callback for handling root directory refresh from the cache. 163 // Callback for handling root directory refresh from the cache.
175 void OnProtoLoaded(LoadRootFeedParams* params); 164 void OnProtoLoaded(LoadRootFeedParams* params);
176 165
177 // Continues handling root directory refresh after the directory service 166 // Continues handling root directory refresh after the directory service
178 // is fully loaded. 167 // is fully loaded.
179 void ContinueWithInitializedDirectoryService(LoadRootFeedParams* params, 168 void ContinueWithInitializedDirectoryService(LoadRootFeedParams* params,
180 GDataFileError error); 169 GDataFileError error);
181 170
182 // Helper callback for handling results of metadata retrieval initiated from 171 // Helper callback for handling results of metadata retrieval initiated from
183 // ReloadFeedFromServerIfNeeded(). This method makes a decision about fetching 172 // ReloadFeedFromServerIfNeeded(). This method makes a decision about fetching
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 241
253 // Note: This should remain the last member so it'll be destroyed and 242 // Note: This should remain the last member so it'll be destroyed and
254 // invalidate its weak pointers before any other members are destroyed. 243 // invalidate its weak pointers before any other members are destroyed.
255 base::WeakPtrFactory<GDataWapiFeedLoader> weak_ptr_factory_; 244 base::WeakPtrFactory<GDataWapiFeedLoader> weak_ptr_factory_;
256 DISALLOW_COPY_AND_ASSIGN(GDataWapiFeedLoader); 245 DISALLOW_COPY_AND_ASSIGN(GDataWapiFeedLoader);
257 }; 246 };
258 247
259 } // namespace gdata 248 } // namespace gdata
260 249
261 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_ 250 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.cc ('k') | chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698