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 "chrome/browser/chromeos/drive/change_list_processor.h" | 5 #include "chrome/browser/chromeos/drive/change_list_processor.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "chrome/browser/chromeos/drive/drive.pb.h" | 10 #include "chrome/browser/chromeos/drive/drive.pb.h" |
11 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | |
11 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" | 12 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" |
12 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 13 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
13 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 14 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
15 | 16 |
16 using content::BrowserThread; | 17 using content::BrowserThread; |
17 | 18 |
18 namespace drive { | 19 namespace drive { |
19 | 20 |
20 namespace { | 21 namespace { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 num_hosted_documents_); | 53 num_hosted_documents_); |
53 UMA_HISTOGRAM_COUNTS("Drive.NumberOfTotalFiles", num_total_files); | 54 UMA_HISTOGRAM_COUNTS("Drive.NumberOfTotalFiles", num_total_files); |
54 } | 55 } |
55 | 56 |
56 private: | 57 private: |
57 int num_regular_files_; | 58 int num_regular_files_; |
58 int num_hosted_documents_; | 59 int num_hosted_documents_; |
59 }; | 60 }; |
60 | 61 |
61 ChangeListProcessor::ChangeListProcessor( | 62 ChangeListProcessor::ChangeListProcessor( |
62 DriveResourceMetadata* resource_metadata) | 63 DriveResourceMetadata* resource_metadata, |
64 const std::string drive_root_resource_id) | |
hidehiko
2013/03/15 06:57:44
Let's make this an argument of ApplyFeeds().
I thi
Haruki Sato
2013/03/18 04:20:25
Done. Thank you for the advice!
| |
63 : resource_metadata_(resource_metadata), | 65 : resource_metadata_(resource_metadata), |
66 drive_root_resource_id_(drive_root_resource_id), | |
64 largest_changestamp_(0), | 67 largest_changestamp_(0), |
65 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 68 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
69 DCHECK(!drive_root_resource_id_.empty()); | |
66 } | 70 } |
67 | 71 |
68 ChangeListProcessor::~ChangeListProcessor() { | 72 ChangeListProcessor::~ChangeListProcessor() { |
69 } | 73 } |
70 | 74 |
71 void ChangeListProcessor::ApplyFeeds( | 75 void ChangeListProcessor::ApplyFeeds( |
72 const ScopedVector<google_apis::ResourceList>& feed_list, | 76 const ScopedVector<google_apis::ResourceList>& feed_list, |
73 bool is_delta_feed, | 77 bool is_delta_feed, |
74 int64 root_feed_changestamp, | 78 int64 root_feed_changestamp, |
75 const base::Closure& on_complete_callback) { | 79 const base::Closure& on_complete_callback) { |
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
77 DCHECK(!on_complete_callback.is_null()); | 81 DCHECK(!on_complete_callback.is_null()); |
78 | 82 |
79 int64 delta_feed_changestamp = 0; | 83 int64 delta_feed_changestamp = 0; |
80 ChangeListToEntryProtoMapUMAStats uma_stats; | 84 ChangeListToEntryProtoMapUMAStats uma_stats; |
85 | |
81 FeedToEntryProtoMap(feed_list, &delta_feed_changestamp, &uma_stats); | 86 FeedToEntryProtoMap(feed_list, &delta_feed_changestamp, &uma_stats); |
82 // Note FeedToEntryProtoMap calls Clear() which resets on_complete_callback_. | 87 // Note FeedToEntryProtoMap calls Clear() which resets on_complete_callback_. |
83 on_complete_callback_ = on_complete_callback; | 88 on_complete_callback_ = on_complete_callback; |
84 largest_changestamp_ = | 89 largest_changestamp_ = |
85 is_delta_feed ? delta_feed_changestamp : root_feed_changestamp; | 90 is_delta_feed ? delta_feed_changestamp : root_feed_changestamp; |
91 | |
92 // TODO(haruki): Add psuedo tree structure fo "drive"/root" and | |
93 // "drive/other" when we start using those namespaces. | |
86 ApplyEntryProtoMap(is_delta_feed); | 94 ApplyEntryProtoMap(is_delta_feed); |
87 | 95 |
88 // Shouldn't record histograms when processing delta feeds. | 96 // Shouldn't record histograms when processing delta feeds. |
89 if (!is_delta_feed) | 97 if (!is_delta_feed) |
90 uma_stats.UpdateFileCountUmaHistograms(); | 98 uma_stats.UpdateFileCountUmaHistograms(); |
91 } | 99 } |
92 | 100 |
93 void ChangeListProcessor::ApplyEntryProtoMap(bool is_delta_feed) { | 101 void ChangeListProcessor::ApplyEntryProtoMap(bool is_delta_feed) { |
94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
95 | 103 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 453 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
446 | 454 |
447 entry_proto_map_.clear(); | 455 entry_proto_map_.clear(); |
448 changed_dirs_.clear(); | 456 changed_dirs_.clear(); |
449 root_upload_url_ = GURL(); | 457 root_upload_url_ = GURL(); |
450 largest_changestamp_ = 0; | 458 largest_changestamp_ = 0; |
451 on_complete_callback_.Reset(); | 459 on_complete_callback_.Reset(); |
452 } | 460 } |
453 | 461 |
454 } // namespace drive | 462 } // namespace drive |
OLD | NEW |