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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/folder_creator.cc

Issue 558603002: [SyncFS] Make MetadataDatabase operations synchronous (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_create
Patch Set: +TODO Created 6 years, 3 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
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/folder_creator.h" 5 #include "chrome/browser/sync_file_system/drive_backend/folder_creator.h"
6 6
7 #include "chrome/browser/drive/drive_api_util.h" 7 #include "chrome/browser/drive/drive_api_util.h"
8 #include "chrome/browser/drive/drive_service_interface.h" 8 #include "chrome/browser/drive/drive_service_interface.h"
9 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" 9 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h"
10 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" 10 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 oldest = &entry; 106 oldest = &entry;
107 } 107 }
108 108
109 if (!oldest) { 109 if (!oldest) {
110 callback.Run(std::string(), SYNC_FILE_ERROR_NOT_FOUND); 110 callback.Run(std::string(), SYNC_FILE_ERROR_NOT_FOUND);
111 return; 111 return;
112 } 112 }
113 113
114 std::string file_id = oldest->file_id(); 114 std::string file_id = oldest->file_id();
115 115
116 metadata_database_->UpdateByFileResourceList( 116 status = metadata_database_->UpdateByFileResourceList(candidates.Pass());
117 candidates.Pass(), base::Bind(&FolderCreator::DidUpdateDatabase, 117
118 weak_ptr_factory_.GetWeakPtr(), 118 // TODO(tzik): Expand this function.
119 file_id, callback)); 119 DidUpdateDatabase(file_id, callback, status);
120 } 120 }
121 121
122 void FolderCreator::DidUpdateDatabase(const std::string& file_id, 122 void FolderCreator::DidUpdateDatabase(const std::string& file_id,
123 const FileIDCallback& callback, 123 const FileIDCallback& callback,
124 SyncStatusCode status) { 124 SyncStatusCode status) {
125 if (status != SYNC_STATUS_OK) { 125 if (status != SYNC_STATUS_OK) {
126 callback.Run(std::string(), status); 126 callback.Run(std::string(), status);
127 return; 127 return;
128 } 128 }
129 129
130 DCHECK(!file_id.empty()); 130 DCHECK(!file_id.empty());
131 if (!metadata_database_->FindFileByFileID(file_id, NULL)) { 131 if (!metadata_database_->FindFileByFileID(file_id, NULL)) {
132 callback.Run(std::string(), SYNC_FILE_ERROR_NOT_FOUND); 132 callback.Run(std::string(), SYNC_FILE_ERROR_NOT_FOUND);
133 return; 133 return;
134 } 134 }
135 135
136 callback.Run(file_id, status); 136 callback.Run(file_id, status);
137 } 137 }
138 138
139 } // namespace drive_backend 139 } // namespace drive_backend
140 } // namespace sync_file_system 140 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698