Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: chrome/browser/chromeos/drive/change_list_processor.cc

Issue 13456002: drive: Fills no-parent entiries in "/drive/other". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a comment in ConvertResourceEntryToDriveEntryProto(). Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } else if (about_resource.get()) { 105 } else if (about_resource.get()) {
106 largest_changestamp_ = about_resource->largest_change_id(); 106 largest_changestamp_ = about_resource->largest_change_id();
107 107
108 DVLOG(1) << "Root folder ID is " << about_resource->root_folder_id(); 108 DVLOG(1) << "Root folder ID is " << about_resource->root_folder_id();
109 DCHECK(!about_resource->root_folder_id().empty()); 109 DCHECK(!about_resource->root_folder_id().empty());
110 } else { 110 } else {
111 // A full update without AboutResouce will have no effective changestamp. 111 // A full update without AboutResouce will have no effective changestamp.
112 NOTREACHED(); 112 NOTREACHED();
113 } 113 }
114 114
115 // TODO(haruki): Add pseudo tree structure for "drive"/root" and "drive/other"
116 // when we start using those namespaces. The root folder ID is necessary for
117 // full feed update.
118 ApplyEntryProtoMap(is_delta_feed); 115 ApplyEntryProtoMap(is_delta_feed);
119 116
120 // Shouldn't record histograms when processing delta feeds. 117 // Shouldn't record histograms when processing delta feeds.
121 if (!is_delta_feed) 118 if (!is_delta_feed)
122 uma_stats.UpdateFileCountUmaHistograms(); 119 uma_stats.UpdateFileCountUmaHistograms();
123 } 120 }
124 121
125 void ChangeListProcessor::ApplyEntryProtoMap(bool is_delta_feed) { 122 void ChangeListProcessor::ApplyEntryProtoMap(bool is_delta_feed) {
126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
127 124
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 // Iterate over |entries| with pop_back() to avoid redundant memory usage, 374 // Iterate over |entries| with pop_back() to avoid redundant memory usage,
378 // there is no need to have duplicated copies of DriveEntryProto in 375 // there is no need to have duplicated copies of DriveEntryProto in
379 // |entries| and |entry_proto_map_| at the same time. 376 // |entries| and |entry_proto_map_| at the same time.
380 std::vector<DriveEntryProto>* entries = change_list->mutable_entries(); 377 std::vector<DriveEntryProto>* entries = change_list->mutable_entries();
381 for (; !entries->empty(); entries->pop_back()) { 378 for (; !entries->empty(); entries->pop_back()) {
382 const DriveEntryProto& entry_proto = entries->back(); 379 const DriveEntryProto& entry_proto = entries->back();
383 // Some document entries don't map into files (i.e. sites). 380 // Some document entries don't map into files (i.e. sites).
384 if (entry_proto.resource_id().empty()) 381 if (entry_proto.resource_id().empty())
385 continue; 382 continue;
386 383
387 // TODO(haruki): Apply mapping from an empty parent to special dummy
388 // directory here or in ConvertResourceEntryToDriveEntryProto. See
389 // http://crbug.com/174233 http://crbug.com/171207. Until we implement it,
390 // ChangeListProcessor ignores such "no parent" entries.
391 // Please note that this will cause a temporal issue when
392 // - The user unselect all the parent using drive.google.com UI.
393 // ChangeListProcessor just ignores the incoming changes and keeps stale
394 // metadata. We need to work on this ASAP to reduce confusion.
395 if (entry_proto.parent_resource_id().empty()) {
396 continue;
397 }
398
399 // Count the number of files. 384 // Count the number of files.
400 if (uma_stats && !entry_proto.file_info().is_directory()) { 385 if (uma_stats && !entry_proto.file_info().is_directory()) {
401 uma_stats->IncrementNumFiles( 386 uma_stats->IncrementNumFiles(
402 entry_proto.file_specific_info().is_hosted_document()); 387 entry_proto.file_specific_info().is_hosted_document());
403 } 388 }
389 // TODO(haruki): Metric for the num of the entries in "other" directory.
404 390
405 std::pair<DriveEntryProtoMap::iterator, bool> ret = entry_proto_map_. 391 std::pair<DriveEntryProtoMap::iterator, bool> ret = entry_proto_map_.
406 insert(std::make_pair(entry_proto.resource_id(), entry_proto)); 392 insert(std::make_pair(entry_proto.resource_id(), entry_proto));
407 DCHECK(ret.second); 393 DCHECK(ret.second);
408 if (!ret.second) 394 if (!ret.second)
409 LOG(WARNING) << "Found duplicate file " << entry_proto.base_name(); 395 LOG(WARNING) << "Found duplicate file " << entry_proto.base_name();
410 } 396 }
411 } 397 }
412 } 398 }
413 399
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 462 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
477 463
478 entry_proto_map_.clear(); 464 entry_proto_map_.clear();
479 changed_dirs_.clear(); 465 changed_dirs_.clear();
480 root_upload_url_ = GURL(); 466 root_upload_url_ = GURL();
481 largest_changestamp_ = 0; 467 largest_changestamp_ = 0;
482 on_complete_callback_.Reset(); 468 on_complete_callback_.Reset();
483 } 469 }
484 470
485 } // namespace drive 471 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698