OLD | NEW |
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/gdata_directory_service.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_directory_service.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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 321 |
322 void GDataDirectoryService::GetEntryByResourceIdAsync( | 322 void GDataDirectoryService::GetEntryByResourceIdAsync( |
323 const std::string& resource_id, | 323 const std::string& resource_id, |
324 const GetEntryByResourceIdCallback& callback) { | 324 const GetEntryByResourceIdCallback& callback) { |
325 GDataEntry* entry = GetEntryByResourceId(resource_id); | 325 GDataEntry* entry = GetEntryByResourceId(resource_id); |
326 callback.Run(entry); | 326 callback.Run(entry); |
327 } | 327 } |
328 | 328 |
329 void GDataDirectoryService::GetEntryInfoByResourceId( | 329 void GDataDirectoryService::GetEntryInfoByResourceId( |
330 const std::string& resource_id, | 330 const std::string& resource_id, |
331 const GetEntryInfoCallback& callback) { | 331 const GetEntryInfoWithFilePathCallback& callback) { |
332 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 332 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
333 DCHECK(!callback.is_null()); | 333 DCHECK(!callback.is_null()); |
334 | 334 |
335 scoped_ptr<GDataEntryProto> entry_proto; | 335 scoped_ptr<GDataEntryProto> entry_proto; |
336 GDataFileError error = GDATA_FILE_ERROR_FAILED; | 336 GDataFileError error = GDATA_FILE_ERROR_FAILED; |
| 337 FilePath drive_file_path; |
337 | 338 |
338 GDataEntry* entry = GetEntryByResourceId(resource_id); | 339 GDataEntry* entry = GetEntryByResourceId(resource_id); |
339 if (entry) { | 340 if (entry) { |
340 entry_proto.reset(new GDataEntryProto); | 341 entry_proto.reset(new GDataEntryProto); |
341 entry->ToProtoFull(entry_proto.get()); | 342 entry->ToProtoFull(entry_proto.get()); |
342 error = GDATA_FILE_OK; | 343 error = GDATA_FILE_OK; |
| 344 drive_file_path = entry->GetFilePath(); |
343 } else { | 345 } else { |
344 error = GDATA_FILE_ERROR_NOT_FOUND; | 346 error = GDATA_FILE_ERROR_NOT_FOUND; |
345 } | 347 } |
346 | 348 |
347 base::MessageLoopProxy::current()->PostTask( | 349 base::MessageLoopProxy::current()->PostTask( |
348 FROM_HERE, | 350 FROM_HERE, |
349 base::Bind(callback, error, base::Passed(&entry_proto))); | 351 base::Bind(callback, |
| 352 error, |
| 353 drive_file_path, |
| 354 base::Passed(&entry_proto))); |
350 } | 355 } |
351 | 356 |
352 void GDataDirectoryService::GetEntryInfoByPath( | 357 void GDataDirectoryService::GetEntryInfoByPath( |
353 const FilePath& path, | 358 const FilePath& path, |
354 const GetEntryInfoCallback& callback) { | 359 const GetEntryInfoCallback& callback) { |
355 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
356 DCHECK(!callback.is_null()); | 361 DCHECK(!callback.is_null()); |
357 | 362 |
358 scoped_ptr<GDataEntryProto> entry_proto; | 363 scoped_ptr<GDataEntryProto> entry_proto; |
359 GDataFileError error = GDATA_FILE_ERROR_FAILED; | 364 GDataFileError error = GDATA_FILE_ERROR_FAILED; |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 DCHECK(result.get()); | 748 DCHECK(result.get()); |
744 | 749 |
745 result->second.path = second_path; | 750 result->second.path = second_path; |
746 result->second.error = error; | 751 result->second.error = error; |
747 result->second.proto = entry_proto.Pass(); | 752 result->second.proto = entry_proto.Pass(); |
748 | 753 |
749 callback.Run(result.Pass()); | 754 callback.Run(result.Pass()); |
750 } | 755 } |
751 | 756 |
752 } // namespace gdata | 757 } // namespace gdata |
OLD | NEW |