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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 DriveResourceMetadata* resource_metadata) | 63 DriveResourceMetadata* resource_metadata) |
63 : resource_metadata_(resource_metadata), | 64 : resource_metadata_(resource_metadata), |
64 largest_changestamp_(0), | 65 largest_changestamp_(0), |
65 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 66 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
66 } | 67 } |
67 | 68 |
68 ChangeListProcessor::~ChangeListProcessor() { | 69 ChangeListProcessor::~ChangeListProcessor() { |
69 } | 70 } |
70 | 71 |
71 void ChangeListProcessor::ApplyFeeds( | 72 void ChangeListProcessor::ApplyFeeds( |
| 73 scoped_ptr<google_apis::AboutResource> about_resource, |
72 const ScopedVector<google_apis::ResourceList>& feed_list, | 74 const ScopedVector<google_apis::ResourceList>& feed_list, |
73 bool is_delta_feed, | 75 bool is_delta_feed, |
74 int64 root_feed_changestamp, | |
75 const base::Closure& on_complete_callback) { | 76 const base::Closure& on_complete_callback) { |
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
77 DCHECK(!on_complete_callback.is_null()); | 78 DCHECK(!on_complete_callback.is_null()); |
| 79 DCHECK(is_delta_feed || about_resource.get()); |
78 | 80 |
79 int64 delta_feed_changestamp = 0; | 81 int64 delta_feed_changestamp = 0; |
80 ChangeListToEntryProtoMapUMAStats uma_stats; | 82 ChangeListToEntryProtoMapUMAStats uma_stats; |
81 FeedToEntryProtoMap(feed_list, &delta_feed_changestamp, &uma_stats); | 83 FeedToEntryProtoMap(feed_list, &delta_feed_changestamp, &uma_stats); |
82 // Note FeedToEntryProtoMap calls Clear() which resets on_complete_callback_. | 84 // Note FeedToEntryProtoMap calls Clear() which resets on_complete_callback_. |
83 on_complete_callback_ = on_complete_callback; | 85 on_complete_callback_ = on_complete_callback; |
84 largest_changestamp_ = | 86 largest_changestamp_ = 0; |
85 is_delta_feed ? delta_feed_changestamp : root_feed_changestamp; | 87 if (is_delta_feed) { |
| 88 largest_changestamp_ = delta_feed_changestamp; |
| 89 } else if (about_resource.get()) { |
| 90 largest_changestamp_ = about_resource->largest_change_id(); |
| 91 |
| 92 DVLOG(1) << "Root folder ID is " << about_resource->root_folder_id(); |
| 93 DCHECK(!about_resource->root_folder_id().empty()); |
| 94 } else { |
| 95 // A full update without AboutResouce will have no effective changestamp. |
| 96 NOTREACHED(); |
| 97 } |
| 98 |
| 99 // TODO(haruki): Add pseudo tree structure for "drive"/root" and "drive/other" |
| 100 // when we start using those namespaces. The root folder ID is necessary for |
| 101 // full feed update. |
86 ApplyEntryProtoMap(is_delta_feed); | 102 ApplyEntryProtoMap(is_delta_feed); |
87 | 103 |
88 // Shouldn't record histograms when processing delta feeds. | 104 // Shouldn't record histograms when processing delta feeds. |
89 if (!is_delta_feed) | 105 if (!is_delta_feed) |
90 uma_stats.UpdateFileCountUmaHistograms(); | 106 uma_stats.UpdateFileCountUmaHistograms(); |
91 } | 107 } |
92 | 108 |
93 void ChangeListProcessor::ApplyEntryProtoMap(bool is_delta_feed) { | 109 void ChangeListProcessor::ApplyEntryProtoMap(bool is_delta_feed) { |
94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
95 | 111 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 461 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
446 | 462 |
447 entry_proto_map_.clear(); | 463 entry_proto_map_.clear(); |
448 changed_dirs_.clear(); | 464 changed_dirs_.clear(); |
449 root_upload_url_ = GURL(); | 465 root_upload_url_ = GURL(); |
450 largest_changestamp_ = 0; | 466 largest_changestamp_ = 0; |
451 on_complete_callback_.Reset(); | 467 on_complete_callback_.Reset(); |
452 } | 468 } |
453 | 469 |
454 } // namespace drive | 470 } // namespace drive |
OLD | NEW |