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

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: 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 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 AddEntryToDirectory(). 2488 // destination directory by AddEntryToDirectory().
2493 directory_service_->root()->AddEntry(entry); 2489 directory_service_->root()->AddEntry(entry);
2494 AddEntryToDirectory(dir_path, callback, GDATA_FILE_OK, entry->GetFilePath()); 2490 AddEntryToDirectory(dir_path, callback, GDATA_FILE_OK, entry->GetFilePath());
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2816 if (!entry) 2812 if (!entry)
2817 return GDATA_FILE_ERROR_FAILED; 2813 return GDATA_FILE_ERROR_FAILED;
2818 2814
2819 // Check if parent is a directory since in theory since this is a callback 2815 // Check if parent is a directory since in theory since this is a callback
2820 // something could in the meantime have nuked the parent dir and created a 2816 // something could in the meantime have nuked the parent dir and created a
2821 // file with the exact same name. 2817 // file with the exact same name.
2822 GDataDirectory* parent_dir = entry->AsGDataDirectory(); 2818 GDataDirectory* parent_dir = entry->AsGDataDirectory();
2823 if (!parent_dir) 2819 if (!parent_dir)
2824 return GDATA_FILE_ERROR_FAILED; 2820 return GDATA_FILE_ERROR_FAILED;
2825 2821
2826 GDataEntry* new_entry = GDataEntry::FromDocumentEntry( 2822 GDataEntry* new_entry =
2827 NULL, doc_entry.get(), directory_service_.get()); 2823 directory_service_->FromDocumentEntry(doc_entry.get());
2828 if (!new_entry) 2824 if (!new_entry)
2829 return GDATA_FILE_ERROR_FAILED; 2825 return GDATA_FILE_ERROR_FAILED;
2830 2826
2831 parent_dir->AddEntry(new_entry); 2827 parent_dir->AddEntry(new_entry);
2832 2828
2833 OnDirectoryChanged(directory_path); 2829 OnDirectoryChanged(directory_path);
2834 return GDATA_FILE_OK; 2830 return GDATA_FILE_OK;
2835 } 2831 }
2836 2832
2837 GDataFileSystem::FindMissingDirectoryResult 2833 GDataFileSystem::FindMissingDirectoryResult
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2939 GDataEntry* dir_entry = directory_service_->FindEntryByPathSync( 2935 GDataEntry* dir_entry = directory_service_->FindEntryByPathSync(
2940 virtual_dir_path); 2936 virtual_dir_path);
2941 if (!dir_entry) 2937 if (!dir_entry)
2942 return; 2938 return;
2943 2939
2944 GDataDirectory* parent_dir = dir_entry->AsGDataDirectory(); 2940 GDataDirectory* parent_dir = dir_entry->AsGDataDirectory();
2945 if (!parent_dir) 2941 if (!parent_dir)
2946 return; 2942 return;
2947 2943
2948 scoped_ptr<GDataEntry> new_entry( 2944 scoped_ptr<GDataEntry> new_entry(
2949 GDataEntry::FromDocumentEntry( 2945 directory_service_->FromDocumentEntry(entry.get()));
2950 NULL, entry.get(), directory_service_.get()));
2951 if (!new_entry.get()) 2946 if (!new_entry.get())
2952 return; 2947 return;
2953 2948
2954 if (upload_mode == UPLOAD_EXISTING_FILE) { 2949 if (upload_mode == UPLOAD_EXISTING_FILE) {
2955 // Remove an existing entry, which should be present. 2950 // Remove an existing entry, which should be present.
2956 const std::string& resource_id = new_entry->resource_id(); 2951 const std::string& resource_id = new_entry->resource_id();
2957 directory_service_->GetEntryByResourceIdAsync(resource_id, 2952 directory_service_->GetEntryByResourceIdAsync(resource_id,
2958 base::Bind(&RemoveStaleEntryOnUpload, resource_id, parent_dir)); 2953 base::Bind(&RemoveStaleEntryOnUpload, resource_id, parent_dir));
2959 } 2954 }
2960 2955
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
3445 } 3440 }
3446 3441
3447 PlatformFileInfoProto entry_file_info; 3442 PlatformFileInfoProto entry_file_info;
3448 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); 3443 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info);
3449 *entry_proto->mutable_file_info() = entry_file_info; 3444 *entry_proto->mutable_file_info() = entry_file_info;
3450 if (!callback.is_null()) 3445 if (!callback.is_null())
3451 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); 3446 callback.Run(GDATA_FILE_OK, entry_proto.Pass());
3452 } 3447 }
3453 3448
3454 } // namespace gdata 3449 } // namespace gdata
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_files.h » ('j') | chrome/browser/chromeos/gdata/gdata_files.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698