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

Side by Side Diff: chrome/browser/chromeos/drive/gdata_wapi_feed_processor.cc

Issue 11106007: drive: Rename 'gdata' namespace to 'drive' in chrome/browser/chromeos/drive (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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 #include <utility> 5 #include <utility>
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/chromeos/drive/drive_files.h" 8 #include "chrome/browser/chromeos/drive/drive_files.h"
9 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" 9 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h"
10 #include "chrome/browser/chromeos/drive/gdata_wapi_feed_processor.h" 10 #include "chrome/browser/chromeos/drive/gdata_wapi_feed_processor.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 12
13 using content::BrowserThread; 13 using content::BrowserThread;
14 14
15 namespace gdata { 15 namespace drive {
16 16
17 FeedToFileResourceMapUmaStats::FeedToFileResourceMapUmaStats() 17 FeedToFileResourceMapUmaStats::FeedToFileResourceMapUmaStats()
18 : num_regular_files(0), 18 : num_regular_files(0),
19 num_hosted_documents(0) { 19 num_hosted_documents(0) {
20 } 20 }
21 21
22 FeedToFileResourceMapUmaStats::~FeedToFileResourceMapUmaStats() { 22 FeedToFileResourceMapUmaStats::~FeedToFileResourceMapUmaStats() {
23 } 23 }
24 24
25 GDataWapiFeedProcessor::GDataWapiFeedProcessor( 25 GDataWapiFeedProcessor::GDataWapiFeedProcessor(
26 DriveResourceMetadata* resource_metadata) 26 DriveResourceMetadata* resource_metadata)
27 : resource_metadata_(resource_metadata) { 27 : resource_metadata_(resource_metadata) {
28 } 28 }
29 29
30 GDataWapiFeedProcessor::~GDataWapiFeedProcessor() { 30 GDataWapiFeedProcessor::~GDataWapiFeedProcessor() {
31 } 31 }
32 32
33 DriveFileError GDataWapiFeedProcessor::ApplyFeeds( 33 DriveFileError GDataWapiFeedProcessor::ApplyFeeds(
34 const ScopedVector<DocumentFeed>& feed_list, 34 const ScopedVector<gdata::DocumentFeed>& feed_list,
35 int64 start_changestamp, 35 int64 start_changestamp,
36 int64 root_feed_changestamp, 36 int64 root_feed_changestamp,
37 std::set<FilePath>* changed_dirs) { 37 std::set<FilePath>* changed_dirs) {
38 bool is_delta_feed = start_changestamp != 0; 38 bool is_delta_feed = start_changestamp != 0;
39 39
40 resource_metadata_->set_origin(FROM_SERVER); 40 resource_metadata_->set_origin(FROM_SERVER);
41 41
42 int64 delta_feed_changestamp = 0; 42 int64 delta_feed_changestamp = 0;
43 FeedToFileResourceMapUmaStats uma_stats; 43 FeedToFileResourceMapUmaStats uma_stats;
44 FileResourceIdMap file_map; 44 FileResourceIdMap file_map;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } else { 221 } else {
222 DVLOG(1) << "Adding orphan " << new_entry->GetFilePath().value(); 222 DVLOG(1) << "Adding orphan " << new_entry->GetFilePath().value();
223 dir = orphaned_resources->root(); 223 dir = orphaned_resources->root();
224 } 224 }
225 } 225 }
226 } 226 }
227 return dir; 227 return dir;
228 } 228 }
229 229
230 DriveFileError GDataWapiFeedProcessor::FeedToFileResourceMap( 230 DriveFileError GDataWapiFeedProcessor::FeedToFileResourceMap(
231 const ScopedVector<DocumentFeed>& feed_list, 231 const ScopedVector<gdata::DocumentFeed>& feed_list,
232 FileResourceIdMap* file_map, 232 FileResourceIdMap* file_map,
233 int64* feed_changestamp, 233 int64* feed_changestamp,
234 FeedToFileResourceMapUmaStats* uma_stats) { 234 FeedToFileResourceMapUmaStats* uma_stats) {
235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
236 DCHECK(uma_stats); 236 DCHECK(uma_stats);
237 237
238 DriveFileError error = DRIVE_FILE_OK; 238 DriveFileError error = DRIVE_FILE_OK;
239 uma_stats->num_regular_files = 0; 239 uma_stats->num_regular_files = 0;
240 uma_stats->num_hosted_documents = 0; 240 uma_stats->num_hosted_documents = 0;
241 for (size_t i = 0; i < feed_list.size(); ++i) { 241 for (size_t i = 0; i < feed_list.size(); ++i) {
242 const DocumentFeed* feed = feed_list[i]; 242 const gdata::DocumentFeed* feed = feed_list[i];
243 243
244 // Get upload url from the root feed. Links for all other collections will 244 // Get upload url from the root feed. Links for all other collections will
245 // be handled in GDatadirectory::FromDocumentEntry(); 245 // be handled in GDatadirectory::FromDocumentEntry();
246 if (i == 0) { 246 if (i == 0) {
247 const Link* root_feed_upload_link = 247 const gdata::Link* root_feed_upload_link =
248 feed->GetLinkByType(Link::LINK_RESUMABLE_CREATE_MEDIA); 248 feed->GetLinkByType(gdata::Link::LINK_RESUMABLE_CREATE_MEDIA);
249 if (root_feed_upload_link) 249 if (root_feed_upload_link)
250 resource_metadata_->root()->set_upload_url( 250 resource_metadata_->root()->set_upload_url(
251 root_feed_upload_link->href()); 251 root_feed_upload_link->href());
252 *feed_changestamp = feed->largest_changestamp(); 252 *feed_changestamp = feed->largest_changestamp();
253 DCHECK_GE(*feed_changestamp, 0); 253 DCHECK_GE(*feed_changestamp, 0);
254 } 254 }
255 255
256 for (ScopedVector<DocumentEntry>::const_iterator iter = 256 for (ScopedVector<gdata::DocumentEntry>::const_iterator iter =
257 feed->entries().begin(); 257 feed->entries().begin();
258 iter != feed->entries().end(); ++iter) { 258 iter != feed->entries().end(); ++iter) {
259 DocumentEntry* doc = *iter; 259 gdata::DocumentEntry* doc = *iter;
260 scoped_ptr<DriveEntry> entry = 260 scoped_ptr<DriveEntry> entry =
261 resource_metadata_->FromDocumentEntry(*doc); 261 resource_metadata_->FromDocumentEntry(*doc);
262 // Some document entries don't map into files (i.e. sites). 262 // Some document entries don't map into files (i.e. sites).
263 if (!entry.get()) 263 if (!entry.get())
264 continue; 264 continue;
265 // Count the number of files. 265 // Count the number of files.
266 DriveFile* as_file = entry->AsDriveFile(); 266 DriveFile* as_file = entry->AsDriveFile();
267 if (as_file) { 267 if (as_file) {
268 if (as_file->is_hosted_document()) 268 if (as_file->is_hosted_document())
269 ++uma_stats->num_hosted_documents; 269 ++uma_stats->num_hosted_documents;
(...skipping 24 matching lines...) Expand all
294 if (error != DRIVE_FILE_OK) { 294 if (error != DRIVE_FILE_OK) {
295 // If the code above fails to parse a feed, any DriveEntry instance 295 // If the code above fails to parse a feed, any DriveEntry instance
296 // added to |file_by_url| is not managed by a DriveDirectory instance, 296 // added to |file_by_url| is not managed by a DriveDirectory instance,
297 // so we need to explicitly release them here. 297 // so we need to explicitly release them here.
298 STLDeleteValues(file_map); 298 STLDeleteValues(file_map);
299 } 299 }
300 300
301 return error; 301 return error;
302 } 302 }
303 303
304 } // namespace gdata 304 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/gdata_wapi_feed_processor.h ('k') | chrome/browser/chromeos/drive/gdata_wapi_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698