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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend_v1/api_util.cc

Issue 140513008: drive: Allow setting modified/accessed date with AddNewDirectory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/sync_file_system/drive_backend_v1/api_util.h" 5 #include "chrome/browser/sync_file_system/drive_backend_v1/api_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <sstream> 9 #include <sstream>
10 #include <string> 10 #include <string>
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 DCHECK(!resource_id.empty()); 333 DCHECK(!resource_id.empty());
334 parent_type = PARENT_TYPE_ROOT_OR_EMPTY; 334 parent_type = PARENT_TYPE_ROOT_OR_EMPTY;
335 } else { 335 } else {
336 resource_id = parent_resource_id; 336 resource_id = parent_resource_id;
337 } 337 }
338 std::string title(directory_name); 338 std::string title(directory_name);
339 google_apis::ResourceEntry* entry = GetDocumentByTitleAndParent( 339 google_apis::ResourceEntry* entry = GetDocumentByTitleAndParent(
340 feed->entries(), title, resource_id, parent_type); 340 feed->entries(), title, resource_id, parent_type);
341 if (!entry) { 341 if (!entry) {
342 DVLOG(2) << "Directory not found. Creating: " << directory_name; 342 DVLOG(2) << "Directory not found. Creating: " << directory_name;
343 drive_service_->AddNewDirectory(resource_id, 343 drive_service_->AddNewDirectory(
344 directory_name, 344 resource_id,
345 base::Bind(&APIUtil::DidCreateDirectory, 345 directory_name,
346 AsWeakPtr(), 346 drive::DriveServiceInterface::AddNewDirectoryOptions(),
347 parent_resource_id, 347 base::Bind(&APIUtil::DidCreateDirectory,
348 title, 348 AsWeakPtr(),
349 callback)); 349 parent_resource_id,
350 title,
351 callback));
350 return; 352 return;
351 } 353 }
352 DVLOG(2) << "Found Drive directory."; 354 DVLOG(2) << "Found Drive directory.";
353 355
354 // TODO(tzik): Handle error. 356 // TODO(tzik): Handle error.
355 DCHECK_EQ(google_apis::ENTRY_KIND_FOLDER, entry->kind()); 357 DCHECK_EQ(google_apis::ENTRY_KIND_FOLDER, entry->kind());
356 DCHECK_EQ(directory_name, entry->title()); 358 DCHECK_EQ(directory_name, entry->title());
357 359
358 if (entry->title() == GetSyncRootDirectoryName()) 360 if (entry->title() == GetSyncRootDirectoryName())
359 EnsureSyncRootIsNotInMyDrive(entry->resource_id()); 361 EnsureSyncRootIsNotInMyDrive(entry->resource_id());
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 562 }
561 563
562 void APIUtil::CreateDirectory(const std::string& parent_resource_id, 564 void APIUtil::CreateDirectory(const std::string& parent_resource_id,
563 const std::string& title, 565 const std::string& title,
564 const ResourceIdCallback& callback) { 566 const ResourceIdCallback& callback) {
565 DCHECK(CalledOnValidThread()); 567 DCHECK(CalledOnValidThread());
566 // TODO(kinuko): This will call EnsureTitleUniqueness and will delete 568 // TODO(kinuko): This will call EnsureTitleUniqueness and will delete
567 // directories if there're duplicated directories. This must be ok 569 // directories if there're duplicated directories. This must be ok
568 // for current design but we'll need to merge directories when we support 570 // for current design but we'll need to merge directories when we support
569 // 'real' directories. 571 // 'real' directories.
570 drive_service_->AddNewDirectory(parent_resource_id, 572 drive_service_->AddNewDirectory(
571 title, 573 parent_resource_id,
572 base::Bind(&APIUtil::DidCreateDirectory, 574 title,
573 AsWeakPtr(), 575 drive::DriveServiceInterface::AddNewDirectoryOptions(),
574 parent_resource_id, 576 base::Bind(&APIUtil::DidCreateDirectory,
575 title, 577 AsWeakPtr(),
576 callback)); 578 parent_resource_id,
579 title,
580 callback));
577 } 581 }
578 582
579 void APIUtil::DeleteFile(const std::string& resource_id, 583 void APIUtil::DeleteFile(const std::string& resource_id,
580 const std::string& remote_file_md5, 584 const std::string& remote_file_md5,
581 const GDataErrorCallback& callback) { 585 const GDataErrorCallback& callback) {
582 DCHECK(CalledOnValidThread()); 586 DCHECK(CalledOnValidThread());
583 DVLOG(2) << "Deleting file: " << resource_id; 587 DVLOG(2) << "Deleting file: " << resource_id;
584 588
585 // Load actual remote_file_md5 to check for conflict before deletion. 589 // Load actual remote_file_md5 to check for conflict before deletion.
586 if (!remote_file_md5.empty()) { 590 if (!remote_file_md5.empty()) {
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 } 1131 }
1128 1132
1129 std::string APIUtil::GetRootResourceId() const { 1133 std::string APIUtil::GetRootResourceId() const {
1130 if (IsDriveAPIDisabled()) 1134 if (IsDriveAPIDisabled())
1131 return drive_service_->GetRootResourceId(); 1135 return drive_service_->GetRootResourceId();
1132 return root_resource_id_; 1136 return root_resource_id_;
1133 } 1137 }
1134 1138
1135 } // namespace drive_backend 1139 } // namespace drive_backend
1136 } // namespace sync_file_system 1140 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698