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

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

Issue 10876075: AddEntryToDirectory now takes a FilePath and scoped_ptr<DocumentEntry> (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: delete FindEntryCallback Created 8 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 | 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/gdata/drive_resource_metadata.h" 5 #include "chrome/browser/chromeos/gdata/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 24 matching lines...) Expand all
35 35
36 EntryInfoResult::~EntryInfoResult() { 36 EntryInfoResult::~EntryInfoResult() {
37 } 37 }
38 38
39 EntryInfoPairResult::EntryInfoPairResult() { 39 EntryInfoPairResult::EntryInfoPairResult() {
40 } 40 }
41 41
42 EntryInfoPairResult::~EntryInfoPairResult() { 42 EntryInfoPairResult::~EntryInfoPairResult() {
43 } 43 }
44 44
45 void PostError(const FileMoveCallback& callback, DriveFileError error) {
hashimoto 2012/08/27 20:36:41 Move this to the anonymous namespace.
achuithb 2012/08/27 21:20:34 Sorry thought I had. Done.
46 base::MessageLoopProxy::current()->PostTask(FROM_HERE,
47 base::Bind(callback, error, FilePath()));
48 }
49
45 // ResourceMetadataDB implementation. 50 // ResourceMetadataDB implementation.
46 51
47 // Params for ResourceMetadataDB::Create. 52 // Params for ResourceMetadataDB::Create.
48 struct CreateDBParams { 53 struct CreateDBParams {
49 CreateDBParams(const FilePath& db_path, 54 CreateDBParams(const FilePath& db_path,
50 base::SequencedTaskRunner* blocking_task_runner) 55 base::SequencedTaskRunner* blocking_task_runner)
51 : db_path(db_path), 56 : db_path(db_path),
52 blocking_task_runner(blocking_task_runner) { 57 blocking_task_runner(blocking_task_runner) {
53 } 58 }
54 59
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // Note that children have a reference to root_, 218 // Note that children have a reference to root_,
214 // so we need to delete them here. 219 // so we need to delete them here.
215 root_->RemoveChildren(); 220 root_->RemoveChildren();
216 RemoveEntryFromResourceMap(root_->resource_id()); 221 RemoveEntryFromResourceMap(root_->resource_id());
217 DCHECK(resource_map_.empty()); 222 DCHECK(resource_map_.empty());
218 resource_map_.clear(); 223 resource_map_.clear();
219 root_.reset(); 224 root_.reset();
220 } 225 }
221 226
222 void DriveResourceMetadata::AddEntryToDirectory( 227 void DriveResourceMetadata::AddEntryToDirectory(
223 DriveDirectory* directory, 228 const FilePath& directory_path,
224 DriveEntry* new_entry, 229 scoped_ptr<DocumentEntry> doc_entry,
225 const FileMoveCallback& callback) { 230 const FileMoveCallback& callback) {
226 DCHECK(directory); 231 DCHECK(!directory_path.empty());
227 DCHECK(new_entry); 232 DCHECK(doc_entry.get());
228 DCHECK(!callback.is_null()); 233 DCHECK(!callback.is_null());
229 234
235 if (!doc_entry.get()) {
hashimoto 2012/08/27 20:36:41 Can we remove this since we have DCHECK(doc_entry.
achuithb 2012/08/27 21:20:34 I think we need this. Removed the DCHECK. We are g
236 PostError(callback, DRIVE_FILE_ERROR_FAILED);
237 return;
238 }
239
240 DriveEntry* new_entry = FromDocumentEntry(*doc_entry);
241 if (!new_entry) {
242 PostError(callback, DRIVE_FILE_ERROR_FAILED);
243 return;
244 }
245
246 DriveEntry* dir_entry = FindEntryByPathSync(directory_path);
247 if (!dir_entry) {
248 PostError(callback, DRIVE_FILE_ERROR_NOT_FOUND);
249 return;
250 }
251
252 DriveDirectory* directory = dir_entry->AsDriveDirectory();
253 if (!directory) {
254 PostError(callback, DRIVE_FILE_ERROR_NOT_A_DIRECTORY);
255 return;
256 }
257
230 directory->AddEntry(new_entry); 258 directory->AddEntry(new_entry);
231 DVLOG(1) << "AddEntryToDirectory " << new_entry->GetFilePath().value(); 259 DVLOG(1) << "AddEntryToDirectory " << new_entry->GetFilePath().value();
232 base::MessageLoopProxy::current()->PostTask(FROM_HERE, 260 base::MessageLoopProxy::current()->PostTask(FROM_HERE,
233 base::Bind(callback, DRIVE_FILE_OK, new_entry->GetFilePath())); 261 base::Bind(callback, DRIVE_FILE_OK, new_entry->GetFilePath()));
234 } 262 }
235 263
236 void DriveResourceMetadata::MoveEntryToDirectory( 264 void DriveResourceMetadata::MoveEntryToDirectory(
237 const FilePath& directory_path, 265 const FilePath& directory_path,
238 DriveEntry* entry, 266 DriveEntry* entry,
239 const FileMoveCallback& callback) { 267 const FileMoveCallback& callback) {
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 DCHECK(result.get()); 804 DCHECK(result.get());
777 805
778 result->second.path = second_path; 806 result->second.path = second_path;
779 result->second.error = error; 807 result->second.error = error;
780 result->second.proto = entry_proto.Pass(); 808 result->second.proto = entry_proto.Pass();
781 809
782 callback.Run(result.Pass()); 810 callback.Run(result.Pass());
783 } 811 }
784 812
785 } // namespace gdata 813 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698