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

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

Issue 10854180: Pass const ref instead of pointer for FromDocumentEntry() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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/gdata_file_system.h" 5 #include "chrome/browser/chromeos/gdata/gdata_file_system.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 const GetFileFromCacheParams& params, 1813 const GetFileFromCacheParams& params,
1814 GDataErrorCode status, 1814 GDataErrorCode status,
1815 scoped_ptr<base::Value> data) { 1815 scoped_ptr<base::Value> data) {
1816 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1816 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1817 1817
1818 GDataFileError error = util::GDataToGDataFileError(status); 1818 GDataFileError error = util::GDataToGDataFileError(status);
1819 1819
1820 scoped_ptr<GDataEntry> fresh_entry; 1820 scoped_ptr<GDataEntry> fresh_entry;
1821 if (error == GDATA_FILE_OK) { 1821 if (error == GDATA_FILE_OK) {
1822 scoped_ptr<DocumentEntry> doc_entry(DocumentEntry::ExtractAndParse(*data)); 1822 scoped_ptr<DocumentEntry> doc_entry(DocumentEntry::ExtractAndParse(*data));
1823 if (doc_entry.get()) { 1823 if (doc_entry.get())
1824 fresh_entry.reset(directory_service_->FromDocumentEntry(doc_entry.get())); 1824 fresh_entry.reset(directory_service_->FromDocumentEntry(*doc_entry));
hashimoto 2012/08/16 06:22:54 GDataDirecotryService::FromDocumentEntry's behavio
kochi 2012/08/16 06:41:34 Filed http://crbug.com/143105.
1825 }
1826 if (!fresh_entry.get() || !fresh_entry->AsGDataFile()) { 1825 if (!fresh_entry.get() || !fresh_entry->AsGDataFile()) {
1827 LOG(ERROR) << "Got invalid entry from server for " << params.resource_id; 1826 LOG(ERROR) << "Got invalid entry from server for " << params.resource_id;
1828 error = GDATA_FILE_ERROR_FAILED; 1827 error = GDATA_FILE_ERROR_FAILED;
1829 } 1828 }
1830 } 1829 }
1831 1830
1832 if (error != GDATA_FILE_OK) { 1831 if (error != GDATA_FILE_OK) {
1833 if (!params.get_file_callback.is_null()) { 1832 if (!params.get_file_callback.is_null()) {
1834 params.get_file_callback.Run(error, 1833 params.get_file_callback.Run(error,
1835 cache_file_path, 1834 cache_file_path,
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2379 scoped_ptr<std::vector<SearchResultInfo> > result_vec(results); 2378 scoped_ptr<std::vector<SearchResultInfo> > result_vec(results);
2380 if (!callback.is_null()) 2379 if (!callback.is_null())
2381 callback.Run(error, next_feed, result_vec.Pass()); 2380 callback.Run(error, next_feed, result_vec.Pass());
2382 return; 2381 return;
2383 } 2382 }
2384 2383
2385 // Go through all entires generated by the feed and add them to the search 2384 // Go through all entires generated by the feed and add them to the search
2386 // result directory. 2385 // result directory.
2387 for (size_t i = 0; i < feed->entries().size(); ++i) { 2386 for (size_t i = 0; i < feed->entries().size(); ++i) {
2388 DocumentEntry* doc = const_cast<DocumentEntry*>(feed->entries()[i]); 2387 DocumentEntry* doc = const_cast<DocumentEntry*>(feed->entries()[i]);
2389 scoped_ptr<GDataEntry> entry(directory_service_->FromDocumentEntry(doc)); 2388 scoped_ptr<GDataEntry> entry(directory_service_->FromDocumentEntry(*doc));
2390 2389
2391 if (!entry.get()) 2390 if (!entry.get())
2392 continue; 2391 continue;
2393 2392
2394 DCHECK_EQ(doc->resource_id(), entry->resource_id()); 2393 DCHECK_EQ(doc->resource_id(), entry->resource_id());
2395 DCHECK(!entry->is_deleted()); 2394 DCHECK(!entry->is_deleted());
2396 2395
2397 std::string entry_resource_id = entry->resource_id(); 2396 std::string entry_resource_id = entry->resource_id();
2398 2397
2399 // This will do nothing if the entry is not already present in file system. 2398 // This will do nothing if the entry is not already present in file system.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 callback.Run(error); 2514 callback.Run(error);
2516 return; 2515 return;
2517 } 2516 }
2518 2517
2519 scoped_ptr<DocumentEntry> doc_entry(DocumentEntry::ExtractAndParse(*data)); 2518 scoped_ptr<DocumentEntry> doc_entry(DocumentEntry::ExtractAndParse(*data));
2520 if (!doc_entry.get()) { 2519 if (!doc_entry.get()) {
2521 callback.Run(GDATA_FILE_ERROR_FAILED); 2520 callback.Run(GDATA_FILE_ERROR_FAILED);
2522 return; 2521 return;
2523 } 2522 }
2524 2523
2525 GDataEntry* entry = directory_service_->FromDocumentEntry(doc_entry.get()); 2524 GDataEntry* entry = directory_service_->FromDocumentEntry(*doc_entry);
2526 if (!entry) { 2525 if (!entry) {
2527 callback.Run(GDATA_FILE_ERROR_FAILED); 2526 callback.Run(GDATA_FILE_ERROR_FAILED);
2528 return; 2527 return;
2529 } 2528 }
2530 2529
2531 // |entry| was added in the root directory on the server, so we should 2530 // |entry| was added in the root directory on the server, so we should
2532 // first add it to |root_| to mirror the state and then move it to the 2531 // first add it to |root_| to mirror the state and then move it to the
2533 // destination directory by MoveEntryFromRootDirectory(). 2532 // destination directory by MoveEntryFromRootDirectory().
2534 directory_service_->AddEntryToDirectory( 2533 directory_service_->AddEntryToDirectory(
2535 directory_service_->root(), 2534 directory_service_->root(),
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 return GDATA_FILE_ERROR_FAILED; 2877 return GDATA_FILE_ERROR_FAILED;
2879 2878
2880 // Check if parent is a directory since in theory since this is a callback 2879 // Check if parent is a directory since in theory since this is a callback
2881 // something could in the meantime have nuked the parent dir and created a 2880 // something could in the meantime have nuked the parent dir and created a
2882 // file with the exact same name. 2881 // file with the exact same name.
2883 GDataDirectory* parent_dir = entry->AsGDataDirectory(); 2882 GDataDirectory* parent_dir = entry->AsGDataDirectory();
2884 if (!parent_dir) 2883 if (!parent_dir)
2885 return GDATA_FILE_ERROR_FAILED; 2884 return GDATA_FILE_ERROR_FAILED;
2886 2885
2887 GDataEntry* new_entry = 2886 GDataEntry* new_entry =
2888 directory_service_->FromDocumentEntry(doc_entry.get()); 2887 directory_service_->FromDocumentEntry(*doc_entry);
2889 if (!new_entry) 2888 if (!new_entry)
2890 return GDATA_FILE_ERROR_FAILED; 2889 return GDATA_FILE_ERROR_FAILED;
2891 2890
2892 directory_service_->AddEntryToDirectory( 2891 directory_service_->AddEntryToDirectory(
2893 parent_dir, 2892 parent_dir,
2894 new_entry, 2893 new_entry,
2895 base::Bind(&GDataFileSystem::NotifyAndRunFileMoveCallback, 2894 base::Bind(&GDataFileSystem::NotifyAndRunFileMoveCallback,
2896 ui_weak_ptr_, 2895 ui_weak_ptr_,
2897 FileMoveCallback())); 2896 FileMoveCallback()));
2898 return GDATA_FILE_OK; 2897 return GDATA_FILE_OK;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
3003 GDataEntry* dir_entry = directory_service_->FindEntryByPathSync( 3002 GDataEntry* dir_entry = directory_service_->FindEntryByPathSync(
3004 virtual_dir_path); 3003 virtual_dir_path);
3005 if (!dir_entry) 3004 if (!dir_entry)
3006 return; 3005 return;
3007 3006
3008 GDataDirectory* parent_dir = dir_entry->AsGDataDirectory(); 3007 GDataDirectory* parent_dir = dir_entry->AsGDataDirectory();
3009 if (!parent_dir) 3008 if (!parent_dir)
3010 return; 3009 return;
3011 3010
3012 scoped_ptr<GDataEntry> new_entry( 3011 scoped_ptr<GDataEntry> new_entry(
3013 directory_service_->FromDocumentEntry(entry.get())); 3012 directory_service_->FromDocumentEntry(*entry));
3014 if (!new_entry.get()) 3013 if (!new_entry.get())
3015 return; 3014 return;
3016 3015
3017 const std::string& resource_id = new_entry->resource_id(); 3016 const std::string& resource_id = new_entry->resource_id();
3018 AddUploadedFileParams* params = 3017 AddUploadedFileParams* params =
3019 new AddUploadedFileParams(upload_mode, 3018 new AddUploadedFileParams(upload_mode,
3020 parent_dir, 3019 parent_dir,
3021 new_entry.Pass(), 3020 new_entry.Pass(),
3022 file_content_path, 3021 file_content_path,
3023 cache_operation, 3022 cache_operation,
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
3456 return; 3455 return;
3457 } 3456 }
3458 3457
3459 PlatformFileInfoProto entry_file_info; 3458 PlatformFileInfoProto entry_file_info;
3460 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); 3459 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info);
3461 *entry_proto->mutable_file_info() = entry_file_info; 3460 *entry_proto->mutable_file_info() = entry_file_info;
3462 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); 3461 callback.Run(GDATA_FILE_OK, entry_proto.Pass());
3463 } 3462 }
3464 3463
3465 } // namespace gdata 3464 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698