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

Side by Side Diff: chrome/browser/google_apis/fake_drive_service.cc

Issue 13436003: Fix FakeDriveService's behavior to be more correct. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | no next file » | 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/google_apis/fake_drive_service.h" 5 #include "chrome/browser/google_apis/fake_drive_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 803 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
804 DCHECK(!callback.is_null()); 804 DCHECK(!callback.is_null());
805 805
806 if (offline_) { 806 if (offline_) {
807 MessageLoop::current()->PostTask( 807 MessageLoop::current()->PostTask(
808 FROM_HERE, 808 FROM_HERE,
809 base::Bind(callback, GDATA_NO_CONNECTION, GURL())); 809 base::Bind(callback, GDATA_NO_CONNECTION, GURL()));
810 return; 810 return;
811 } 811 }
812 812
813 DictionaryValue* entry = FindEntryByResourceId(parent_resource_id); 813 if (parent_resource_id != GetRootResourceId() &&
814 if (!entry) { 814 !FindEntryByResourceId(parent_resource_id)) {
815 MessageLoop::current()->PostTask( 815 MessageLoop::current()->PostTask(
816 FROM_HERE, 816 FROM_HERE,
817 base::Bind(callback, HTTP_NOT_FOUND, GURL())); 817 base::Bind(callback, HTTP_NOT_FOUND, GURL()));
818 return; 818 return;
819 } 819 }
820 820
821 // If the title was set, the upload_location is the location of the parent 821 // If the title was set, the upload_location is the location of the parent
822 // directory of the file that will be uploaded. The file does not yet exist 822 // directory of the file that will be uploaded. The file does not yet exist
823 // and it must be created. Its title will be the passed title param. 823 // and it must be created. Its title will be the passed title param.
824 std::string resource_id = GetNewResourceId(); 824 std::string resource_id = GetNewResourceId();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 DictionaryValue* entry = FindEntryByResourceId(resource_id); 911 DictionaryValue* entry = FindEntryByResourceId(resource_id);
912 if (!entry) { 912 if (!entry) {
913 MessageLoop::current()->PostTask( 913 MessageLoop::current()->PostTask(
914 FROM_HERE, 914 FROM_HERE,
915 base::Bind(callback, HTTP_NOT_FOUND, GURL())); 915 base::Bind(callback, HTTP_NOT_FOUND, GURL()));
916 return; 916 return;
917 } 917 }
918 918
919 std::string entry_etag; 919 std::string entry_etag;
920 entry->GetString("gd$etag", &entry_etag); 920 entry->GetString("gd$etag", &entry_etag);
921 if (etag != entry_etag) { 921 if (!etag.empty() && etag != entry_etag) {
922 MessageLoop::current()->PostTask( 922 MessageLoop::current()->PostTask(
923 FROM_HERE, 923 FROM_HERE,
924 base::Bind(callback, HTTP_PRECONDITION, GURL())); 924 base::Bind(callback, HTTP_PRECONDITION, GURL()));
925 return; 925 return;
926 } 926 }
927 927
928 std::string upload_url; 928 std::string upload_url;
929 base::ListValue* links = NULL; 929 base::ListValue* links = NULL;
930 if (entry->GetList("link", &links) && links) { 930 if (entry->GetList("link", &links) && links) {
931 for (size_t link_index = 0; 931 for (size_t link_index = 0;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 return base::StringPrintf("resource_id_%d", resource_id_count_); 1121 return base::StringPrintf("resource_id_%d", resource_id_count_);
1122 } 1122 }
1123 1123
1124 void FakeDriveService::AddNewChangestamp(base::DictionaryValue* entry) { 1124 void FakeDriveService::AddNewChangestamp(base::DictionaryValue* entry) {
1125 ++largest_changestamp_; 1125 ++largest_changestamp_;
1126 entry->SetString("docs$changestamp.value", 1126 entry->SetString("docs$changestamp.value",
1127 base::Int64ToString(largest_changestamp_)); 1127 base::Int64ToString(largest_changestamp_));
1128 } 1128 }
1129 1129
1130 } // namespace google_apis 1130 } // namespace google_apis
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698