| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } else if (about_resource.get()) { | 102 } else if (about_resource.get()) { |
| 103 largest_changestamp_ = about_resource->largest_change_id(); | 103 largest_changestamp_ = about_resource->largest_change_id(); |
| 104 | 104 |
| 105 DVLOG(1) << "Root folder ID is " << about_resource->root_folder_id(); | 105 DVLOG(1) << "Root folder ID is " << about_resource->root_folder_id(); |
| 106 DCHECK(!about_resource->root_folder_id().empty()); | 106 DCHECK(!about_resource->root_folder_id().empty()); |
| 107 } else { | 107 } else { |
| 108 // A full update without AboutResouce will have no effective changestamp. | 108 // A full update without AboutResouce will have no effective changestamp. |
| 109 NOTREACHED(); | 109 NOTREACHED(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 // TODO(haruki): Add pseudo tree structure for "drive"/root" and "drive/other" | |
| 113 // when we start using those namespaces. The root folder ID is necessary for | |
| 114 // full feed update. | |
| 115 ApplyEntryProtoMap(is_delta_feed); | 112 ApplyEntryProtoMap(is_delta_feed); |
| 116 | 113 |
| 117 // Shouldn't record histograms when processing delta feeds. | 114 // Shouldn't record histograms when processing delta feeds. |
| 118 if (!is_delta_feed) | 115 if (!is_delta_feed) |
| 119 uma_stats.UpdateFileCountUmaHistograms(); | 116 uma_stats.UpdateFileCountUmaHistograms(); |
| 120 } | 117 } |
| 121 | 118 |
| 122 void ChangeListProcessor::ApplyEntryProtoMap(bool is_delta_feed) { | 119 void ChangeListProcessor::ApplyEntryProtoMap(bool is_delta_feed) { |
| 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 124 | 121 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 DCHECK_GE(change_list->largest_changestamp(), 0); | 365 DCHECK_GE(change_list->largest_changestamp(), 0); |
| 369 } | 366 } |
| 370 | 367 |
| 371 std::vector<DriveEntryProto>* entries = change_list->mutable_entries(); | 368 std::vector<DriveEntryProto>* entries = change_list->mutable_entries(); |
| 372 for (size_t i = 0; i < entries->size(); ++i) { | 369 for (size_t i = 0; i < entries->size(); ++i) { |
| 373 DriveEntryProto* entry_proto = &(*entries)[i]; | 370 DriveEntryProto* entry_proto = &(*entries)[i]; |
| 374 // Some document entries don't map into files (i.e. sites). | 371 // Some document entries don't map into files (i.e. sites). |
| 375 if (entry_proto->resource_id().empty()) | 372 if (entry_proto->resource_id().empty()) |
| 376 continue; | 373 continue; |
| 377 | 374 |
| 378 // TODO(haruki): Apply mapping from an empty parent to special dummy | |
| 379 // directory here or in ConvertResourceEntryToDriveEntryProto. See | |
| 380 // http://crbug.com/174233 http://crbug.com/171207. Until we implement it, | |
| 381 // ChangeListProcessor ignores such "no parent" entries. | |
| 382 // Please note that this will cause a temporal issue when | |
| 383 // - The user unselect all the parent using drive.google.com UI. | |
| 384 // ChangeListProcessor just ignores the incoming changes and keeps stale | |
| 385 // metadata. We need to work on this ASAP to reduce confusion. | |
| 386 if (entry_proto->parent_resource_id().empty()) { | |
| 387 continue; | |
| 388 } | |
| 389 | |
| 390 // Count the number of files. | 375 // Count the number of files. |
| 391 if (uma_stats && !entry_proto->file_info().is_directory()) { | 376 if (uma_stats && !entry_proto->file_info().is_directory()) { |
| 392 uma_stats->IncrementNumFiles( | 377 uma_stats->IncrementNumFiles( |
| 393 entry_proto->file_specific_info().is_hosted_document()); | 378 entry_proto->file_specific_info().is_hosted_document()); |
| 394 } | 379 } |
| 380 // TODO(haruki): Metric for the num of the entries in "other" directory. |
| 395 | 381 |
| 396 std::pair<DriveEntryProtoMap::iterator, bool> ret = entry_proto_map_. | 382 std::pair<DriveEntryProtoMap::iterator, bool> ret = entry_proto_map_. |
| 397 insert(std::make_pair(entry_proto->resource_id(), DriveEntryProto())); | 383 insert(std::make_pair(entry_proto->resource_id(), DriveEntryProto())); |
| 398 if (ret.second) | 384 if (ret.second) |
| 399 ret.first->second.Swap(entry_proto); | 385 ret.first->second.Swap(entry_proto); |
| 400 else | 386 else |
| 401 LOG(DFATAL) << "Found duplicate file " << entry_proto->base_name(); | 387 LOG(DFATAL) << "Found duplicate file " << entry_proto->base_name(); |
| 402 } | 388 } |
| 403 } | 389 } |
| 404 } | 390 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 void ChangeListProcessor::Clear() { | 449 void ChangeListProcessor::Clear() { |
| 464 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 450 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 465 | 451 |
| 466 entry_proto_map_.clear(); | 452 entry_proto_map_.clear(); |
| 467 changed_dirs_.clear(); | 453 changed_dirs_.clear(); |
| 468 largest_changestamp_ = 0; | 454 largest_changestamp_ = 0; |
| 469 on_complete_callback_.Reset(); | 455 on_complete_callback_.Reset(); |
| 470 } | 456 } |
| 471 | 457 |
| 472 } // namespace drive | 458 } // namespace drive |
| OLD | NEW |