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

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

Issue 11227020: Set root resource ID upon full feed update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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/drive_resource_metadata.h" 5 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h"
6 6
7 #include <leveldb/db.h> 7 #include <leveldb/db.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 scoped_ptr<DriveFile> DriveResourceMetadata::CreateDriveFile() { 215 scoped_ptr<DriveFile> DriveResourceMetadata::CreateDriveFile() {
216 return scoped_ptr<DriveFile>(new DriveFile(this)); 216 return scoped_ptr<DriveFile>(new DriveFile(this));
217 } 217 }
218 218
219 scoped_ptr<DriveDirectory> DriveResourceMetadata::CreateDriveDirectory() { 219 scoped_ptr<DriveDirectory> DriveResourceMetadata::CreateDriveDirectory() {
220 return scoped_ptr<DriveDirectory>(new DriveDirectory(this)); 220 return scoped_ptr<DriveDirectory>(new DriveDirectory(this));
221 } 221 }
222 222
223 void DriveResourceMetadata::InitializeRootEntry(const std::string& root_id) { 223 void DriveResourceMetadata::InitializeRootEntry(const std::string& root_id) {
224 DCHECK(root_resource_id_.empty());
225 root_resource_id_ = root_id;
224 root_ = CreateDriveDirectory().Pass(); 226 root_ = CreateDriveDirectory().Pass();
225 root_->set_title(kDriveRootDirectory); 227 root_->set_title(kDriveRootDirectory);
226 root_->SetBaseNameFromTitle(); 228 root_->SetBaseNameFromTitle();
227 root_->set_resource_id(root_id); 229 root_->set_resource_id(root_id);
228 AddEntryToResourceMap(root_.get()); 230 AddEntryToResourceMap(root_.get());
229 } 231 }
230 232
231 void DriveResourceMetadata::ClearRoot() { 233 void DriveResourceMetadata::ClearRoot() {
232 if (!root_.get()) 234 if (!root_.get())
233 return; 235 return;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 MoveEntryToDirectory(file_path, entry->parent()->GetFilePath(), callback); 348 MoveEntryToDirectory(file_path, entry->parent()->GetFilePath(), callback);
347 } 349 }
348 350
349 void DriveResourceMetadata::RemoveEntryFromParent( 351 void DriveResourceMetadata::RemoveEntryFromParent(
350 const std::string& resource_id, 352 const std::string& resource_id,
351 const FileMoveCallback& callback) { 353 const FileMoveCallback& callback) {
352 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
353 DCHECK(!callback.is_null()); 355 DCHECK(!callback.is_null());
354 356
355 // Disallow deletion of root. 357 // Disallow deletion of root.
356 if (resource_id == kDriveRootDirectoryResourceId) { 358 if (resource_id == root_resource_id_) {
357 PostFileMoveCallbackError(callback, DRIVE_FILE_ERROR_ACCESS_DENIED); 359 PostFileMoveCallbackError(callback, DRIVE_FILE_ERROR_ACCESS_DENIED);
358 return; 360 return;
359 } 361 }
360 362
361 DriveEntry* entry = GetEntryByResourceId(resource_id); 363 DriveEntry* entry = GetEntryByResourceId(resource_id);
362 if (!entry) { 364 if (!entry) {
363 PostFileMoveCallbackError(callback, DRIVE_FILE_ERROR_NOT_FOUND); 365 PostFileMoveCallbackError(callback, DRIVE_FILE_ERROR_NOT_FOUND);
364 return; 366 return;
365 } 367 }
366 368
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 resource_map.find(entry->parent_resource_id()); 705 resource_map.find(entry->parent_resource_id());
704 if (parent_it != resource_map.end()) { 706 if (parent_it != resource_map.end()) {
705 DriveDirectory* parent = parent_it->second->AsDriveDirectory(); 707 DriveDirectory* parent = parent_it->second->AsDriveDirectory();
706 if (parent) { 708 if (parent) {
707 DVLOG(1) << "Adding " << entry->resource_id() 709 DVLOG(1) << "Adding " << entry->resource_id()
708 << " as a child of " << parent->resource_id(); 710 << " as a child of " << parent->resource_id();
709 parent->AddEntry(entry); 711 parent->AddEntry(entry);
710 } else { 712 } else {
711 NOTREACHED() << "Parent is not a directory " << parent->resource_id(); 713 NOTREACHED() << "Parent is not a directory " << parent->resource_id();
712 } 714 }
713 } else if (entry->resource_id() == kDriveRootDirectoryResourceId) { 715 } else if (entry->resource_id() == root_resource_id_) {
714 root_.reset(entry->AsDriveDirectory()); 716 root_.reset(entry->AsDriveDirectory());
715 DCHECK(root_.get()); 717 DCHECK(root_.get());
716 AddEntryToResourceMap(root_.get()); 718 AddEntryToResourceMap(root_.get());
717 } else { 719 } else {
718 NOTREACHED() << "Missing parent id " << entry->parent_resource_id() 720 NOTREACHED() << "Missing parent id " << entry->parent_resource_id()
719 << " for resource " << entry->resource_id(); 721 << " for resource " << entry->resource_id();
720 } 722 }
721 } 723 }
722 724
723 if (!root_.get()) { 725 if (!root_.get()) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 DCHECK(result.get()); 867 DCHECK(result.get());
866 868
867 result->second.path = second_path; 869 result->second.path = second_path;
868 result->second.error = error; 870 result->second.error = error;
869 result->second.proto = entry_proto.Pass(); 871 result->second.proto = entry_proto.Pass();
870 872
871 callback.Run(result.Pass()); 873 callback.Run(result.Pass());
872 } 874 }
873 875
874 } // namespace drive 876 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698