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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 return iter == resource_map_.end() ? NULL : iter->second; | 319 return iter == resource_map_.end() ? NULL : iter->second; |
320 } | 320 } |
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( |
| 330 const std::string& resource_id, |
| 331 const GetEntryInfoCallback& callback) { |
| 332 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 333 DCHECK(!callback.is_null()); |
| 334 |
| 335 scoped_ptr<GDataEntryProto> entry_proto; |
| 336 GDataFileError error = GDATA_FILE_ERROR_FAILED; |
| 337 |
| 338 GDataEntry* entry = GetEntryByResourceId(resource_id); |
| 339 if (entry) { |
| 340 entry_proto.reset(new GDataEntryProto); |
| 341 entry->ToProtoFull(entry_proto.get()); |
| 342 error = GDATA_FILE_OK; |
| 343 } else { |
| 344 error = GDATA_FILE_ERROR_NOT_FOUND; |
| 345 } |
| 346 |
| 347 base::MessageLoopProxy::current()->PostTask( |
| 348 FROM_HERE, |
| 349 base::Bind(callback, error, base::Passed(&entry_proto))); |
| 350 } |
| 351 |
329 void GDataDirectoryService::GetEntryInfoByPath( | 352 void GDataDirectoryService::GetEntryInfoByPath( |
330 const FilePath& path, | 353 const FilePath& path, |
331 const GetEntryInfoCallback& callback) { | 354 const GetEntryInfoCallback& callback) { |
332 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 355 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
333 DCHECK(!callback.is_null()); | 356 DCHECK(!callback.is_null()); |
334 | 357 |
335 scoped_ptr<GDataEntryProto> entry_proto; | 358 scoped_ptr<GDataEntryProto> entry_proto; |
336 GDataFileError error = GDATA_FILE_ERROR_FAILED; | 359 GDataFileError error = GDATA_FILE_ERROR_FAILED; |
337 | 360 |
338 GDataEntry* entry = FindEntryByPathSync(path); | 361 GDataEntry* entry = FindEntryByPathSync(path); |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 DCHECK(result.get()); | 743 DCHECK(result.get()); |
721 | 744 |
722 result->second.path = second_path; | 745 result->second.path = second_path; |
723 result->second.error = error; | 746 result->second.error = error; |
724 result->second.proto = entry_proto.Pass(); | 747 result->second.proto = entry_proto.Pass(); |
725 | 748 |
726 callback.Run(result.Pass()); | 749 callback.Run(result.Pass()); |
727 } | 750 } |
728 | 751 |
729 } // namespace gdata | 752 } // namespace gdata |
OLD | NEW |