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

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

Issue 10854083: Remove parent* arg from GDataEntry ctor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_files.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 GDataErrorCode status, 1738 GDataErrorCode status,
1739 scoped_ptr<base::Value> data) { 1739 scoped_ptr<base::Value> data) {
1740 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1740 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1741 1741
1742 GDataFileError error = util::GDataToGDataFileError(status); 1742 GDataFileError error = util::GDataToGDataFileError(status);
1743 1743
1744 scoped_ptr<GDataEntry> fresh_entry; 1744 scoped_ptr<GDataEntry> fresh_entry;
1745 if (error == GDATA_FILE_OK) { 1745 if (error == GDATA_FILE_OK) {
1746 scoped_ptr<DocumentEntry> doc_entry(DocumentEntry::ExtractAndParse(*data)); 1746 scoped_ptr<DocumentEntry> doc_entry(DocumentEntry::ExtractAndParse(*data));
1747 if (doc_entry.get()) { 1747 if (doc_entry.get()) {
1748 fresh_entry.reset( 1748 fresh_entry.reset(directory_service_->FromDocumentEntry(doc_entry.get()));
1749 GDataEntry::FromDocumentEntry(NULL, doc_entry.get(),
1750 directory_service_.get()));
1751 } 1749 }
1752 if (!fresh_entry.get() || !fresh_entry->AsGDataFile()) { 1750 if (!fresh_entry.get() || !fresh_entry->AsGDataFile()) {
1753 LOG(ERROR) << "Got invalid entry from server for " << params.resource_id; 1751 LOG(ERROR) << "Got invalid entry from server for " << params.resource_id;
1754 error = GDATA_FILE_ERROR_FAILED; 1752 error = GDATA_FILE_ERROR_FAILED;
1755 } 1753 }
1756 } 1754 }
1757 1755
1758 if (error != GDATA_FILE_OK) { 1756 if (error != GDATA_FILE_OK) {
1759 if (!params.get_file_callback.is_null()) { 1757 if (!params.get_file_callback.is_null()) {
1760 params.get_file_callback.Run(error, 1758 params.get_file_callback.Run(error,
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
2333 scoped_ptr<std::vector<SearchResultInfo> > result_vec(results); 2331 scoped_ptr<std::vector<SearchResultInfo> > result_vec(results);
2334 if (!callback.is_null()) 2332 if (!callback.is_null())
2335 callback.Run(error, next_feed, result_vec.Pass()); 2333 callback.Run(error, next_feed, result_vec.Pass());
2336 return; 2334 return;
2337 } 2335 }
2338 2336
2339 // Go through all entires generated by the feed and add them to the search 2337 // Go through all entires generated by the feed and add them to the search
2340 // result directory. 2338 // result directory.
2341 for (size_t i = 0; i < feed->entries().size(); ++i) { 2339 for (size_t i = 0; i < feed->entries().size(); ++i) {
2342 DocumentEntry* doc = const_cast<DocumentEntry*>(feed->entries()[i]); 2340 DocumentEntry* doc = const_cast<DocumentEntry*>(feed->entries()[i]);
2343 scoped_ptr<GDataEntry> entry( 2341 scoped_ptr<GDataEntry> entry(directory_service_->FromDocumentEntry(doc));
2344 GDataEntry::FromDocumentEntry(NULL, doc, directory_service_.get()));
2345 2342
2346 if (!entry.get()) 2343 if (!entry.get())
2347 continue; 2344 continue;
2348 2345
2349 DCHECK_EQ(doc->resource_id(), entry->resource_id()); 2346 DCHECK_EQ(doc->resource_id(), entry->resource_id());
2350 DCHECK(!entry->is_deleted()); 2347 DCHECK(!entry->is_deleted());
2351 2348
2352 std::string entry_resource_id = entry->resource_id(); 2349 std::string entry_resource_id = entry->resource_id();
2353 2350
2354 // This will do nothing if the entry is not already present in file system. 2351 // This will do nothing if the entry is not already present in file system.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 callback.Run(error); 2470 callback.Run(error);
2474 return; 2471 return;
2475 } 2472 }
2476 2473
2477 scoped_ptr<DocumentEntry> doc_entry(DocumentEntry::ExtractAndParse(*data)); 2474 scoped_ptr<DocumentEntry> doc_entry(DocumentEntry::ExtractAndParse(*data));
2478 if (!doc_entry.get()) { 2475 if (!doc_entry.get()) {
2479 callback.Run(GDATA_FILE_ERROR_FAILED); 2476 callback.Run(GDATA_FILE_ERROR_FAILED);
2480 return; 2477 return;
2481 } 2478 }
2482 2479
2483 GDataEntry* entry = GDataEntry::FromDocumentEntry( 2480 GDataEntry* entry = directory_service_->FromDocumentEntry(doc_entry.get());
2484 NULL, doc_entry.get(), directory_service_.get());
2485 if (!entry) { 2481 if (!entry) {
2486 callback.Run(GDATA_FILE_ERROR_FAILED); 2482 callback.Run(GDATA_FILE_ERROR_FAILED);
2487 return; 2483 return;
2488 } 2484 }
2489 2485
2490 // |entry| was added in the root directory on the server, so we should 2486 // |entry| was added in the root directory on the server, so we should
2491 // first add it to |root_| to mirror the state and then move it to the 2487 // first add it to |root_| to mirror the state and then move it to the
2492 // destination directory by MoveEntryFromRootDirectory(). 2488 // destination directory by MoveEntryFromRootDirectory().
2493 directory_service_->root()->AddEntry(entry); 2489 directory_service_->root()->AddEntry(entry);
2494 MoveEntryFromRootDirectory(dir_path, 2490 MoveEntryFromRootDirectory(dir_path,
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
2820 if (!entry) 2816 if (!entry)
2821 return GDATA_FILE_ERROR_FAILED; 2817 return GDATA_FILE_ERROR_FAILED;
2822 2818
2823 // Check if parent is a directory since in theory since this is a callback 2819 // Check if parent is a directory since in theory since this is a callback
2824 // something could in the meantime have nuked the parent dir and created a 2820 // something could in the meantime have nuked the parent dir and created a
2825 // file with the exact same name. 2821 // file with the exact same name.
2826 GDataDirectory* parent_dir = entry->AsGDataDirectory(); 2822 GDataDirectory* parent_dir = entry->AsGDataDirectory();
2827 if (!parent_dir) 2823 if (!parent_dir)
2828 return GDATA_FILE_ERROR_FAILED; 2824 return GDATA_FILE_ERROR_FAILED;
2829 2825
2830 GDataEntry* new_entry = GDataEntry::FromDocumentEntry( 2826 GDataEntry* new_entry =
2831 NULL, doc_entry.get(), directory_service_.get()); 2827 directory_service_->FromDocumentEntry(doc_entry.get());
2832 if (!new_entry) 2828 if (!new_entry)
2833 return GDATA_FILE_ERROR_FAILED; 2829 return GDATA_FILE_ERROR_FAILED;
2834 2830
2835 parent_dir->AddEntry(new_entry); 2831 parent_dir->AddEntry(new_entry);
2836 2832
2837 OnDirectoryChanged(directory_path); 2833 OnDirectoryChanged(directory_path);
2838 return GDATA_FILE_OK; 2834 return GDATA_FILE_OK;
2839 } 2835 }
2840 2836
2841 GDataFileSystem::FindMissingDirectoryResult 2837 GDataFileSystem::FindMissingDirectoryResult
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2943 GDataEntry* dir_entry = directory_service_->FindEntryByPathSync( 2939 GDataEntry* dir_entry = directory_service_->FindEntryByPathSync(
2944 virtual_dir_path); 2940 virtual_dir_path);
2945 if (!dir_entry) 2941 if (!dir_entry)
2946 return; 2942 return;
2947 2943
2948 GDataDirectory* parent_dir = dir_entry->AsGDataDirectory(); 2944 GDataDirectory* parent_dir = dir_entry->AsGDataDirectory();
2949 if (!parent_dir) 2945 if (!parent_dir)
2950 return; 2946 return;
2951 2947
2952 scoped_ptr<GDataEntry> new_entry( 2948 scoped_ptr<GDataEntry> new_entry(
2953 GDataEntry::FromDocumentEntry( 2949 directory_service_->FromDocumentEntry(entry.get()));
2954 NULL, entry.get(), directory_service_.get()));
2955 if (!new_entry.get()) 2950 if (!new_entry.get())
2956 return; 2951 return;
2957 2952
2958 if (upload_mode == UPLOAD_EXISTING_FILE) { 2953 if (upload_mode == UPLOAD_EXISTING_FILE) {
2959 // Remove an existing entry, which should be present. 2954 // Remove an existing entry, which should be present.
2960 const std::string& resource_id = new_entry->resource_id(); 2955 const std::string& resource_id = new_entry->resource_id();
2961 directory_service_->GetEntryByResourceIdAsync(resource_id, 2956 directory_service_->GetEntryByResourceIdAsync(resource_id,
2962 base::Bind(&RemoveStaleEntryOnUpload, resource_id, parent_dir)); 2957 base::Bind(&RemoveStaleEntryOnUpload, resource_id, parent_dir));
2963 } 2958 }
2964 2959
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
3449 } 3444 }
3450 3445
3451 PlatformFileInfoProto entry_file_info; 3446 PlatformFileInfoProto entry_file_info;
3452 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); 3447 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info);
3453 *entry_proto->mutable_file_info() = entry_file_info; 3448 *entry_proto->mutable_file_info() = entry_file_info;
3454 if (!callback.is_null()) 3449 if (!callback.is_null())
3455 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); 3450 callback.Run(GDATA_FILE_OK, entry_proto.Pass());
3456 } 3451 }
3457 3452
3458 } // namespace gdata 3453 } // namespace gdata
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_files.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698