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 #include <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/chromeos/gdata/drive_resource_metadata.h" | 8 #include "chrome/browser/chromeos/gdata/drive_resource_metadata.h" |
9 #include "chrome/browser/chromeos/gdata/drive_files.h" | 9 #include "chrome/browser/chromeos/gdata/drive_files.h" |
10 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h" | 10 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h" |
(...skipping 12 matching lines...) Expand all Loading... |
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 GDataFileError GDataWapiFeedProcessor::ApplyFeeds( | 33 DriveFileError GDataWapiFeedProcessor::ApplyFeeds( |
34 const std::vector<DocumentFeed*>& feed_list, | 34 const std::vector<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; |
45 GDataFileError error = FeedToFileResourceMap(feed_list, | 45 DriveFileError error = FeedToFileResourceMap(feed_list, |
46 &file_map, | 46 &file_map, |
47 &delta_feed_changestamp, | 47 &delta_feed_changestamp, |
48 &uma_stats); | 48 &uma_stats); |
49 if (error != GDATA_FILE_OK) | 49 if (error != DRIVE_FILE_OK) |
50 return error; | 50 return error; |
51 | 51 |
52 ApplyFeedFromFileUrlMap( | 52 ApplyFeedFromFileUrlMap( |
53 is_delta_feed, | 53 is_delta_feed, |
54 is_delta_feed ? delta_feed_changestamp : root_feed_changestamp, | 54 is_delta_feed ? delta_feed_changestamp : root_feed_changestamp, |
55 &file_map, | 55 &file_map, |
56 changed_dirs); | 56 changed_dirs); |
57 | 57 |
58 // Shouldn't record histograms when processing delta feeds. | 58 // Shouldn't record histograms when processing delta feeds. |
59 if (!is_delta_feed) | 59 if (!is_delta_feed) |
60 UpdateFileCountUmaHistograms(uma_stats); | 60 UpdateFileCountUmaHistograms(uma_stats); |
61 | 61 |
62 return GDATA_FILE_OK; | 62 return DRIVE_FILE_OK; |
63 } | 63 } |
64 | 64 |
65 void GDataWapiFeedProcessor::UpdateFileCountUmaHistograms( | 65 void GDataWapiFeedProcessor::UpdateFileCountUmaHistograms( |
66 const FeedToFileResourceMapUmaStats& uma_stats) const { | 66 const FeedToFileResourceMapUmaStats& uma_stats) const { |
67 const int num_total_files = | 67 const int num_total_files = |
68 uma_stats.num_hosted_documents + uma_stats.num_regular_files; | 68 uma_stats.num_hosted_documents + uma_stats.num_regular_files; |
69 UMA_HISTOGRAM_COUNTS("GData.NumberOfRegularFiles", | 69 UMA_HISTOGRAM_COUNTS("GData.NumberOfRegularFiles", |
70 uma_stats.num_regular_files); | 70 uma_stats.num_regular_files); |
71 UMA_HISTOGRAM_COUNTS("GData.NumberOfHostedDocuments", | 71 UMA_HISTOGRAM_COUNTS("GData.NumberOfHostedDocuments", |
72 uma_stats.num_hosted_documents); | 72 uma_stats.num_hosted_documents); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 << " in file_map " << parent_id; | 232 << " in file_map " << parent_id; |
233 } else { | 233 } else { |
234 DVLOG(1) << "Adding orphan " << new_entry->GetFilePath().value(); | 234 DVLOG(1) << "Adding orphan " << new_entry->GetFilePath().value(); |
235 dir = orphaned_resources->root(); | 235 dir = orphaned_resources->root(); |
236 } | 236 } |
237 } | 237 } |
238 } | 238 } |
239 return dir; | 239 return dir; |
240 } | 240 } |
241 | 241 |
242 GDataFileError GDataWapiFeedProcessor::FeedToFileResourceMap( | 242 DriveFileError GDataWapiFeedProcessor::FeedToFileResourceMap( |
243 const std::vector<DocumentFeed*>& feed_list, | 243 const std::vector<DocumentFeed*>& feed_list, |
244 FileResourceIdMap* file_map, | 244 FileResourceIdMap* file_map, |
245 int64* feed_changestamp, | 245 int64* feed_changestamp, |
246 FeedToFileResourceMapUmaStats* uma_stats) { | 246 FeedToFileResourceMapUmaStats* uma_stats) { |
247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
248 DCHECK(uma_stats); | 248 DCHECK(uma_stats); |
249 | 249 |
250 GDataFileError error = GDATA_FILE_OK; | 250 DriveFileError error = DRIVE_FILE_OK; |
251 uma_stats->num_regular_files = 0; | 251 uma_stats->num_regular_files = 0; |
252 uma_stats->num_hosted_documents = 0; | 252 uma_stats->num_hosted_documents = 0; |
253 uma_stats->num_files_with_entry_kind.clear(); | 253 uma_stats->num_files_with_entry_kind.clear(); |
254 for (size_t i = 0; i < feed_list.size(); ++i) { | 254 for (size_t i = 0; i < feed_list.size(); ++i) { |
255 const DocumentFeed* feed = feed_list[i]; | 255 const DocumentFeed* feed = feed_list[i]; |
256 | 256 |
257 // Get upload url from the root feed. Links for all other collections will | 257 // Get upload url from the root feed. Links for all other collections will |
258 // be handled in GDatadirectory::FromDocumentEntry(); | 258 // be handled in GDatadirectory::FromDocumentEntry(); |
259 if (i == 0) { | 259 if (i == 0) { |
260 const Link* root_feed_upload_link = | 260 const Link* root_feed_upload_link = |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 << map_entry->second->base_name(); | 295 << map_entry->second->base_name(); |
296 | 296 |
297 delete map_entry->second; | 297 delete map_entry->second; |
298 file_map->erase(map_entry); | 298 file_map->erase(map_entry); |
299 } | 299 } |
300 file_map->insert( | 300 file_map->insert( |
301 std::pair<std::string, DriveEntry*>(entry->resource_id(), entry)); | 301 std::pair<std::string, DriveEntry*>(entry->resource_id(), entry)); |
302 } | 302 } |
303 } | 303 } |
304 | 304 |
305 if (error != GDATA_FILE_OK) { | 305 if (error != DRIVE_FILE_OK) { |
306 // If the code above fails to parse a feed, any DriveEntry instance | 306 // If the code above fails to parse a feed, any DriveEntry instance |
307 // added to |file_by_url| is not managed by a DriveDirectory instance, | 307 // added to |file_by_url| is not managed by a DriveDirectory instance, |
308 // so we need to explicitly release them here. | 308 // so we need to explicitly release them here. |
309 STLDeleteValues(file_map); | 309 STLDeleteValues(file_map); |
310 } | 310 } |
311 | 311 |
312 return error; | 312 return error; |
313 } | 313 } |
314 | 314 |
315 } // namespace gdata | 315 } // namespace gdata |
OLD | NEW |