| 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" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } else if (about_resource.get()) { | 111 } else if (about_resource.get()) { |
| 112 largest_changestamp_ = about_resource->largest_change_id(); | 112 largest_changestamp_ = about_resource->largest_change_id(); |
| 113 | 113 |
| 114 DVLOG(1) << "Root folder ID is " << about_resource->root_folder_id(); | 114 DVLOG(1) << "Root folder ID is " << about_resource->root_folder_id(); |
| 115 DCHECK(!about_resource->root_folder_id().empty()); | 115 DCHECK(!about_resource->root_folder_id().empty()); |
| 116 } else { | 116 } else { |
| 117 // A full update without AboutResouce will have no effective changestamp. | 117 // A full update without AboutResouce will have no effective changestamp. |
| 118 NOTREACHED(); | 118 NOTREACHED(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 ApplyEntryProtoMap(is_delta_feed); | 121 ApplyEntryProtoMap(is_delta_feed, about_resource.Pass()); |
| 122 | 122 |
| 123 // Shouldn't record histograms when processing delta feeds. | 123 // Shouldn't record histograms when processing delta feeds. |
| 124 if (!is_delta_feed) | 124 if (!is_delta_feed) |
| 125 uma_stats.UpdateFileCountUmaHistograms(); | 125 uma_stats.UpdateFileCountUmaHistograms(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void ChangeListProcessor::ApplyEntryProtoMap(bool is_delta_feed) { | 128 void ChangeListProcessor::ApplyEntryProtoMap( |
| 129 bool is_delta_feed, |
| 130 scoped_ptr<google_apis::AboutResource> about_resource) { |
| 129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 130 | 132 |
| 131 if (!is_delta_feed) { // Full update. | 133 if (!is_delta_feed) { // Full update. |
| 134 DCHECK(about_resource); |
| 135 changed_dirs_.insert(util::GetDriveGrandRootPath()); |
| 132 changed_dirs_.insert(util::GetDriveMyDriveRootPath()); | 136 changed_dirs_.insert(util::GetDriveMyDriveRootPath()); |
| 137 // After all nodes are cleared, create the MyDrive root directory at first. |
| 133 resource_metadata_->RemoveAll( | 138 resource_metadata_->RemoveAll( |
| 134 base::Bind(&ChangeListProcessor::ApplyNextEntryProtoAsync, | 139 base::Bind( |
| 135 weak_ptr_factory_.GetWeakPtr())); | 140 &ChangeListProcessor::ApplyEntryProto, |
| 141 weak_ptr_factory_.GetWeakPtr(), |
| 142 util::CreateMyDriveRootEntry(about_resource->root_folder_id()))); |
| 136 } else { | 143 } else { |
| 137 // Go through all entries generated by the feed and apply them to the local | 144 // Go through all entries generated by the feed and apply them to the local |
| 138 // snapshot of the file system. | 145 // snapshot of the file system. |
| 139 ApplyNextEntryProtoAsync(); | 146 ApplyNextEntryProtoAsync(); |
| 140 } | 147 } |
| 141 } | 148 } |
| 142 | 149 |
| 143 void ChangeListProcessor::ApplyNextEntryProtoAsync() { | 150 void ChangeListProcessor::ApplyNextEntryProtoAsync() { |
| 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 145 | 152 |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 void ChangeListProcessor::Clear() { | 468 void ChangeListProcessor::Clear() { |
| 462 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 469 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 463 | 470 |
| 464 entry_proto_map_.clear(); | 471 entry_proto_map_.clear(); |
| 465 changed_dirs_.clear(); | 472 changed_dirs_.clear(); |
| 466 largest_changestamp_ = 0; | 473 largest_changestamp_ = 0; |
| 467 on_complete_callback_.Reset(); | 474 on_complete_callback_.Reset(); |
| 468 } | 475 } |
| 469 | 476 |
| 470 } // namespace drive | 477 } // namespace drive |
| OLD | NEW |