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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc

Issue 881403003: Rename gdata_errorcode.h to drive_api_error_codes.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typos in BUILD.gn Created 5 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/sync_file_system/drive_backend/fake_drive_service_helpe r.h" 5 #include "chrome/browser/sync_file_system/drive_backend/fake_drive_service_helpe r.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/threading/sequenced_worker_pool.h" 11 #include "base/threading/sequenced_worker_pool.h"
12 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" 12 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h"
13 #include "chrome/browser/sync_file_system/sync_status_code.h" 13 #include "chrome/browser/sync_file_system/sync_status_code.h"
14 #include "google_apis/drive/drive_api_parser.h" 14 #include "google_apis/drive/drive_api_parser.h"
15 #include "storage/browser/fileapi/file_system_url.h" 15 #include "storage/browser/fileapi/file_system_url.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 #define FPL(path) FILE_PATH_LITERAL(path) 18 #define FPL(path) FILE_PATH_LITERAL(path)
19 19
20 using google_apis::AboutResource; 20 using google_apis::AboutResource;
21 using google_apis::FileList; 21 using google_apis::FileList;
22 using google_apis::FileResource; 22 using google_apis::FileResource;
23 using google_apis::GDataErrorCode; 23 using google_apis::DriveApiErrorCode;
mtomasz 2015/01/29 06:18:02 nit: ditto
24 24
25 namespace sync_file_system { 25 namespace sync_file_system {
26 namespace drive_backend { 26 namespace drive_backend {
27 27
28 namespace { 28 namespace {
29 29
30 void UploadResultCallback(GDataErrorCode* error_out, 30 void UploadResultCallback(DriveApiErrorCode* error_out,
31 scoped_ptr<FileResource>* entry_out, 31 scoped_ptr<FileResource>* entry_out,
32 GDataErrorCode error, 32 DriveApiErrorCode error,
33 const GURL& upload_location, 33 const GURL& upload_location,
34 scoped_ptr<FileResource> entry) { 34 scoped_ptr<FileResource> entry) {
35 ASSERT_TRUE(error_out); 35 ASSERT_TRUE(error_out);
36 ASSERT_TRUE(entry_out); 36 ASSERT_TRUE(entry_out);
37 *error_out = error; 37 *error_out = error;
38 *entry_out = entry.Pass(); 38 *entry_out = entry.Pass();
39 } 39 }
40 40
41 void DownloadResultCallback(GDataErrorCode* error_out, 41 void DownloadResultCallback(DriveApiErrorCode* error_out,
42 GDataErrorCode error, 42 DriveApiErrorCode error,
43 const base::FilePath& local_file) { 43 const base::FilePath& local_file) {
44 ASSERT_TRUE(error_out); 44 ASSERT_TRUE(error_out);
45 *error_out = error; 45 *error_out = error;
46 } 46 }
47 47
48 } // namespace 48 } // namespace
49 49
50 FakeDriveServiceHelper::FakeDriveServiceHelper( 50 FakeDriveServiceHelper::FakeDriveServiceHelper(
51 drive::FakeDriveService* fake_drive_service, 51 drive::FakeDriveService* fake_drive_service,
52 drive::DriveUploaderInterface* drive_uploader, 52 drive::DriveUploaderInterface* drive_uploader,
53 const std::string& sync_root_folder_title) 53 const std::string& sync_root_folder_title)
54 : fake_drive_service_(fake_drive_service), 54 : fake_drive_service_(fake_drive_service),
55 drive_uploader_(drive_uploader), 55 drive_uploader_(drive_uploader),
56 sync_root_folder_title_(sync_root_folder_title) { 56 sync_root_folder_title_(sync_root_folder_title) {
57 Initialize(); 57 Initialize();
58 } 58 }
59 59
60 FakeDriveServiceHelper::~FakeDriveServiceHelper() { 60 FakeDriveServiceHelper::~FakeDriveServiceHelper() {
61 } 61 }
62 62
63 GDataErrorCode FakeDriveServiceHelper::AddOrphanedFolder( 63 DriveApiErrorCode FakeDriveServiceHelper::AddOrphanedFolder(
64 const std::string& title, 64 const std::string& title,
65 std::string* folder_id) { 65 std::string* folder_id) {
66 std::string root_folder_id = fake_drive_service_->GetRootResourceId(); 66 std::string root_folder_id = fake_drive_service_->GetRootResourceId();
67 GDataErrorCode error = AddFolder(root_folder_id, title, folder_id); 67 DriveApiErrorCode error = AddFolder(root_folder_id, title, folder_id);
68 if (error != google_apis::HTTP_CREATED) 68 if (error != google_apis::HTTP_CREATED)
69 return error; 69 return error;
70 70
71 error = google_apis::GDATA_OTHER_ERROR; 71 error = google_apis::DRIVE_OTHER_ERROR;
72 fake_drive_service_->RemoveResourceFromDirectory( 72 fake_drive_service_->RemoveResourceFromDirectory(
73 root_folder_id, *folder_id, 73 root_folder_id, *folder_id,
74 CreateResultReceiver(&error)); 74 CreateResultReceiver(&error));
75 base::RunLoop().RunUntilIdle(); 75 base::RunLoop().RunUntilIdle();
76 76
77 if (error != google_apis::HTTP_NO_CONTENT && folder_id) 77 if (error != google_apis::HTTP_NO_CONTENT && folder_id)
78 return error; 78 return error;
79 return google_apis::HTTP_CREATED; 79 return google_apis::HTTP_CREATED;
80 } 80 }
81 81
82 GDataErrorCode FakeDriveServiceHelper::AddFolder( 82 DriveApiErrorCode FakeDriveServiceHelper::AddFolder(
83 const std::string& parent_folder_id, 83 const std::string& parent_folder_id,
84 const std::string& title, 84 const std::string& title,
85 std::string* folder_id) { 85 std::string* folder_id) {
86 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 86 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
87 scoped_ptr<FileResource> folder; 87 scoped_ptr<FileResource> folder;
88 fake_drive_service_->AddNewDirectory( 88 fake_drive_service_->AddNewDirectory(
89 parent_folder_id, title, 89 parent_folder_id, title,
90 drive::DriveServiceInterface::AddNewDirectoryOptions(), 90 drive::DriveServiceInterface::AddNewDirectoryOptions(),
91 CreateResultReceiver(&error, &folder)); 91 CreateResultReceiver(&error, &folder));
92 base::RunLoop().RunUntilIdle(); 92 base::RunLoop().RunUntilIdle();
93 93
94 if (error == google_apis::HTTP_CREATED && folder_id) 94 if (error == google_apis::HTTP_CREATED && folder_id)
95 *folder_id = folder->file_id(); 95 *folder_id = folder->file_id();
96 return error; 96 return error;
97 } 97 }
98 98
99 GDataErrorCode FakeDriveServiceHelper::AddFile( 99 DriveApiErrorCode FakeDriveServiceHelper::AddFile(
100 const std::string& parent_folder_id, 100 const std::string& parent_folder_id,
101 const std::string& title, 101 const std::string& title,
102 const std::string& content, 102 const std::string& content,
103 std::string* file_id) { 103 std::string* file_id) {
104 base::FilePath temp_file = WriteToTempFile(content); 104 base::FilePath temp_file = WriteToTempFile(content);
105 105
106 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 106 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
107 scoped_ptr<FileResource> file; 107 scoped_ptr<FileResource> file;
108 drive_uploader_->UploadNewFile( 108 drive_uploader_->UploadNewFile(
109 parent_folder_id, temp_file, title, 109 parent_folder_id, temp_file, title,
110 "application/octet-stream", 110 "application/octet-stream",
111 drive::DriveUploader::UploadNewFileOptions(), 111 drive::DriveUploader::UploadNewFileOptions(),
112 base::Bind(&UploadResultCallback, &error, &file), 112 base::Bind(&UploadResultCallback, &error, &file),
113 google_apis::ProgressCallback()); 113 google_apis::ProgressCallback());
114 base::RunLoop().RunUntilIdle(); 114 base::RunLoop().RunUntilIdle();
115 115
116 if (error == google_apis::HTTP_SUCCESS && file_id) 116 if (error == google_apis::HTTP_SUCCESS && file_id)
117 *file_id = file->file_id(); 117 *file_id = file->file_id();
118 return error; 118 return error;
119 } 119 }
120 120
121 GDataErrorCode FakeDriveServiceHelper::UpdateFile( 121 DriveApiErrorCode FakeDriveServiceHelper::UpdateFile(
122 const std::string& file_id, 122 const std::string& file_id,
123 const std::string& content) { 123 const std::string& content) {
124 base::FilePath temp_file = WriteToTempFile(content); 124 base::FilePath temp_file = WriteToTempFile(content);
125 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 125 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
126 scoped_ptr<FileResource> file; 126 scoped_ptr<FileResource> file;
127 drive_uploader_->UploadExistingFile( 127 drive_uploader_->UploadExistingFile(
128 file_id, temp_file, 128 file_id, temp_file,
129 "application/octet-stream", 129 "application/octet-stream",
130 drive::DriveUploader::UploadExistingFileOptions(), 130 drive::DriveUploader::UploadExistingFileOptions(),
131 base::Bind(&UploadResultCallback, &error, &file), 131 base::Bind(&UploadResultCallback, &error, &file),
132 google_apis::ProgressCallback()); 132 google_apis::ProgressCallback());
133 base::RunLoop().RunUntilIdle(); 133 base::RunLoop().RunUntilIdle();
134 return error; 134 return error;
135 } 135 }
136 136
137 GDataErrorCode FakeDriveServiceHelper::DeleteResource( 137 DriveApiErrorCode FakeDriveServiceHelper::DeleteResource(
138 const std::string& file_id) { 138 const std::string& file_id) {
139 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 139 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
140 fake_drive_service_->DeleteResource( 140 fake_drive_service_->DeleteResource(
141 file_id, 141 file_id,
142 std::string(), // etag 142 std::string(), // etag
143 CreateResultReceiver(&error)); 143 CreateResultReceiver(&error));
144 base::RunLoop().RunUntilIdle(); 144 base::RunLoop().RunUntilIdle();
145 return error; 145 return error;
146 } 146 }
147 147
148 GDataErrorCode FakeDriveServiceHelper::TrashResource( 148 DriveApiErrorCode FakeDriveServiceHelper::TrashResource(
149 const std::string& file_id) { 149 const std::string& file_id) {
150 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 150 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
151 fake_drive_service_->TrashResource( 151 fake_drive_service_->TrashResource(
152 file_id, 152 file_id,
153 CreateResultReceiver(&error)); 153 CreateResultReceiver(&error));
154 base::RunLoop().RunUntilIdle(); 154 base::RunLoop().RunUntilIdle();
155 return error; 155 return error;
156 } 156 }
157 157
158 GDataErrorCode FakeDriveServiceHelper::UpdateModificationTime( 158 DriveApiErrorCode FakeDriveServiceHelper::UpdateModificationTime(
159 const std::string& file_id, 159 const std::string& file_id,
160 const base::Time& modification_time) { 160 const base::Time& modification_time) {
161 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 161 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
162 scoped_ptr<FileResource> entry; 162 scoped_ptr<FileResource> entry;
163 error = GetFileResource(file_id, &entry); 163 error = GetFileResource(file_id, &entry);
164 if (error != google_apis::HTTP_SUCCESS) 164 if (error != google_apis::HTTP_SUCCESS)
165 return error; 165 return error;
166 166
167 fake_drive_service_->UpdateResource( 167 fake_drive_service_->UpdateResource(
168 file_id, std::string(), entry->title(), 168 file_id, std::string(), entry->title(),
169 modification_time, entry->last_viewed_by_me_date(), 169 modification_time, entry->last_viewed_by_me_date(),
170 CreateResultReceiver(&error, &entry)); 170 CreateResultReceiver(&error, &entry));
171 base::RunLoop().RunUntilIdle(); 171 base::RunLoop().RunUntilIdle();
172 return error; 172 return error;
173 } 173 }
174 174
175 GDataErrorCode FakeDriveServiceHelper::RenameResource( 175 DriveApiErrorCode FakeDriveServiceHelper::RenameResource(
176 const std::string& file_id, 176 const std::string& file_id,
177 const std::string& new_title) { 177 const std::string& new_title) {
178 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 178 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
179 scoped_ptr<FileResource> entry; 179 scoped_ptr<FileResource> entry;
180 fake_drive_service_->UpdateResource( 180 fake_drive_service_->UpdateResource(
181 file_id, std::string(), new_title, base::Time(), base::Time(), 181 file_id, std::string(), new_title, base::Time(), base::Time(),
182 CreateResultReceiver(&error, &entry)); 182 CreateResultReceiver(&error, &entry));
183 base::RunLoop().RunUntilIdle(); 183 base::RunLoop().RunUntilIdle();
184 return error; 184 return error;
185 } 185 }
186 186
187 GDataErrorCode FakeDriveServiceHelper::AddResourceToDirectory( 187 DriveApiErrorCode FakeDriveServiceHelper::AddResourceToDirectory(
188 const std::string& parent_folder_id, 188 const std::string& parent_folder_id,
189 const std::string& file_id) { 189 const std::string& file_id) {
190 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 190 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
191 fake_drive_service_->AddResourceToDirectory( 191 fake_drive_service_->AddResourceToDirectory(
192 parent_folder_id, file_id, 192 parent_folder_id, file_id,
193 CreateResultReceiver(&error)); 193 CreateResultReceiver(&error));
194 base::RunLoop().RunUntilIdle(); 194 base::RunLoop().RunUntilIdle();
195 return error; 195 return error;
196 } 196 }
197 197
198 GDataErrorCode FakeDriveServiceHelper::RemoveResourceFromDirectory( 198 DriveApiErrorCode FakeDriveServiceHelper::RemoveResourceFromDirectory(
199 const std::string& parent_folder_id, 199 const std::string& parent_folder_id,
200 const std::string& file_id) { 200 const std::string& file_id) {
201 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 201 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
202 fake_drive_service_->RemoveResourceFromDirectory( 202 fake_drive_service_->RemoveResourceFromDirectory(
203 parent_folder_id, file_id, 203 parent_folder_id, file_id,
204 CreateResultReceiver(&error)); 204 CreateResultReceiver(&error));
205 base::RunLoop().RunUntilIdle(); 205 base::RunLoop().RunUntilIdle();
206 return error; 206 return error;
207 } 207 }
208 208
209 GDataErrorCode FakeDriveServiceHelper::GetSyncRootFolderID( 209 DriveApiErrorCode FakeDriveServiceHelper::GetSyncRootFolderID(
210 std::string* sync_root_folder_id) { 210 std::string* sync_root_folder_id) {
211 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 211 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
212 scoped_ptr<FileList> resource_list; 212 scoped_ptr<FileList> resource_list;
213 fake_drive_service_->SearchByTitle( 213 fake_drive_service_->SearchByTitle(
214 sync_root_folder_title_, std::string(), 214 sync_root_folder_title_, std::string(),
215 CreateResultReceiver(&error, &resource_list)); 215 CreateResultReceiver(&error, &resource_list));
216 base::RunLoop().RunUntilIdle(); 216 base::RunLoop().RunUntilIdle();
217 if (error != google_apis::HTTP_SUCCESS) 217 if (error != google_apis::HTTP_SUCCESS)
218 return error; 218 return error;
219 219
220 const ScopedVector<FileResource>& items = resource_list->items(); 220 const ScopedVector<FileResource>& items = resource_list->items();
221 for (ScopedVector<FileResource>::const_iterator itr = items.begin(); 221 for (ScopedVector<FileResource>::const_iterator itr = items.begin();
222 itr != items.end(); ++itr) { 222 itr != items.end(); ++itr) {
223 const FileResource& item = **itr; 223 const FileResource& item = **itr;
224 if (item.parents().empty()) { 224 if (item.parents().empty()) {
225 *sync_root_folder_id = item.file_id(); 225 *sync_root_folder_id = item.file_id();
226 return google_apis::HTTP_SUCCESS; 226 return google_apis::HTTP_SUCCESS;
227 } 227 }
228 } 228 }
229 return google_apis::HTTP_NOT_FOUND; 229 return google_apis::HTTP_NOT_FOUND;
230 } 230 }
231 231
232 GDataErrorCode FakeDriveServiceHelper::ListFilesInFolder( 232 DriveApiErrorCode FakeDriveServiceHelper::ListFilesInFolder(
233 const std::string& folder_id, 233 const std::string& folder_id,
234 ScopedVector<FileResource>* entries) { 234 ScopedVector<FileResource>* entries) {
235 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 235 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
236 scoped_ptr<FileList> list; 236 scoped_ptr<FileList> list;
237 fake_drive_service_->GetFileListInDirectory( 237 fake_drive_service_->GetFileListInDirectory(
238 folder_id, 238 folder_id,
239 CreateResultReceiver(&error, &list)); 239 CreateResultReceiver(&error, &list));
240 base::RunLoop().RunUntilIdle(); 240 base::RunLoop().RunUntilIdle();
241 if (error != google_apis::HTTP_SUCCESS) 241 if (error != google_apis::HTTP_SUCCESS)
242 return error; 242 return error;
243 243
244 return CompleteListing(list.Pass(), entries); 244 return CompleteListing(list.Pass(), entries);
245 } 245 }
246 246
247 GDataErrorCode FakeDriveServiceHelper::SearchByTitle( 247 DriveApiErrorCode FakeDriveServiceHelper::SearchByTitle(
248 const std::string& folder_id, 248 const std::string& folder_id,
249 const std::string& title, 249 const std::string& title,
250 ScopedVector<FileResource>* entries) { 250 ScopedVector<FileResource>* entries) {
251 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 251 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
252 scoped_ptr<FileList> list; 252 scoped_ptr<FileList> list;
253 fake_drive_service_->SearchByTitle( 253 fake_drive_service_->SearchByTitle(
254 title, folder_id, 254 title, folder_id,
255 CreateResultReceiver(&error, &list)); 255 CreateResultReceiver(&error, &list));
256 base::RunLoop().RunUntilIdle(); 256 base::RunLoop().RunUntilIdle();
257 if (error != google_apis::HTTP_SUCCESS) 257 if (error != google_apis::HTTP_SUCCESS)
258 return error; 258 return error;
259 259
260 return CompleteListing(list.Pass(), entries); 260 return CompleteListing(list.Pass(), entries);
261 } 261 }
262 262
263 GDataErrorCode FakeDriveServiceHelper::GetFileResource( 263 DriveApiErrorCode FakeDriveServiceHelper::GetFileResource(
264 const std::string& file_id, 264 const std::string& file_id,
265 scoped_ptr<FileResource>* entry) { 265 scoped_ptr<FileResource>* entry) {
266 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 266 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
267 fake_drive_service_->GetFileResource( 267 fake_drive_service_->GetFileResource(
268 file_id, 268 file_id,
269 CreateResultReceiver(&error, entry)); 269 CreateResultReceiver(&error, entry));
270 base::RunLoop().RunUntilIdle(); 270 base::RunLoop().RunUntilIdle();
271 return error; 271 return error;
272 } 272 }
273 273
274 GDataErrorCode FakeDriveServiceHelper::ReadFile( 274 DriveApiErrorCode FakeDriveServiceHelper::ReadFile(
275 const std::string& file_id, 275 const std::string& file_id,
276 std::string* file_content) { 276 std::string* file_content) {
277 scoped_ptr<google_apis::FileResource> file; 277 scoped_ptr<google_apis::FileResource> file;
278 GDataErrorCode error = GetFileResource(file_id, &file); 278 DriveApiErrorCode error = GetFileResource(file_id, &file);
279 if (error != google_apis::HTTP_SUCCESS) 279 if (error != google_apis::HTTP_SUCCESS)
280 return error; 280 return error;
281 if (!file) 281 if (!file)
282 return google_apis::GDATA_PARSE_ERROR; 282 return google_apis::DRIVE_PARSE_ERROR;
283 283
284 error = google_apis::GDATA_OTHER_ERROR; 284 error = google_apis::DRIVE_OTHER_ERROR;
285 base::FilePath temp_file; 285 base::FilePath temp_file;
286 EXPECT_TRUE(base::CreateTemporaryFileInDir(temp_dir_, &temp_file)); 286 EXPECT_TRUE(base::CreateTemporaryFileInDir(temp_dir_, &temp_file));
287 fake_drive_service_->DownloadFile( 287 fake_drive_service_->DownloadFile(
288 temp_file, file->file_id(), 288 temp_file, file->file_id(),
289 base::Bind(&DownloadResultCallback, &error), 289 base::Bind(&DownloadResultCallback, &error),
290 google_apis::GetContentCallback(), 290 google_apis::GetContentCallback(),
291 google_apis::ProgressCallback()); 291 google_apis::ProgressCallback());
292 base::RunLoop().RunUntilIdle(); 292 base::RunLoop().RunUntilIdle();
293 if (error != google_apis::HTTP_SUCCESS) 293 if (error != google_apis::HTTP_SUCCESS)
294 return error; 294 return error;
295 295
296 return base::ReadFileToString(temp_file, file_content) 296 return base::ReadFileToString(temp_file, file_content)
297 ? google_apis::HTTP_SUCCESS : google_apis::GDATA_FILE_ERROR; 297 ? google_apis::HTTP_SUCCESS : google_apis::DRIVE_FILE_ERROR;
298 } 298 }
299 299
300 GDataErrorCode FakeDriveServiceHelper::GetAboutResource( 300 DriveApiErrorCode FakeDriveServiceHelper::GetAboutResource(
301 scoped_ptr<AboutResource>* about_resource) { 301 scoped_ptr<AboutResource>* about_resource) {
302 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 302 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
303 fake_drive_service_->GetAboutResource( 303 fake_drive_service_->GetAboutResource(
304 CreateResultReceiver(&error, about_resource)); 304 CreateResultReceiver(&error, about_resource));
305 base::RunLoop().RunUntilIdle(); 305 base::RunLoop().RunUntilIdle();
306 return error; 306 return error;
307 } 307 }
308 308
309 GDataErrorCode FakeDriveServiceHelper::CompleteListing( 309 DriveApiErrorCode FakeDriveServiceHelper::CompleteListing(
310 scoped_ptr<FileList> list, 310 scoped_ptr<FileList> list,
311 ScopedVector<FileResource>* entries) { 311 ScopedVector<FileResource>* entries) {
312 while (true) { 312 while (true) {
313 entries->reserve(entries->size() + list->items().size()); 313 entries->reserve(entries->size() + list->items().size());
314 std::vector<FileResource*> tmp; 314 std::vector<FileResource*> tmp;
315 list->mutable_items()->release(&tmp); 315 list->mutable_items()->release(&tmp);
316 for (std::vector<FileResource*>::const_iterator itr = 316 for (std::vector<FileResource*>::const_iterator itr =
317 tmp.begin(); itr != tmp.end(); ++itr) { 317 tmp.begin(); itr != tmp.end(); ++itr) {
318 entries->push_back(*itr); 318 entries->push_back(*itr);
319 } 319 }
320 320
321 GURL next_feed = list->next_link(); 321 GURL next_feed = list->next_link();
322 if (next_feed.is_empty()) 322 if (next_feed.is_empty())
323 return google_apis::HTTP_SUCCESS; 323 return google_apis::HTTP_SUCCESS;
324 324
325 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 325 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
326 list.reset(); 326 list.reset();
327 fake_drive_service_->GetRemainingFileList( 327 fake_drive_service_->GetRemainingFileList(
328 next_feed, 328 next_feed,
329 CreateResultReceiver(&error, &list)); 329 CreateResultReceiver(&error, &list));
330 base::RunLoop().RunUntilIdle(); 330 base::RunLoop().RunUntilIdle();
331 if (error != google_apis::HTTP_SUCCESS) 331 if (error != google_apis::HTTP_SUCCESS)
332 return error; 332 return error;
333 } 333 }
334 } 334 }
335 335
336 void FakeDriveServiceHelper::Initialize() { 336 void FakeDriveServiceHelper::Initialize() {
337 ASSERT_TRUE(base_dir_.CreateUniqueTempDir()); 337 ASSERT_TRUE(base_dir_.CreateUniqueTempDir());
338 temp_dir_ = base_dir_.path().Append(FPL("tmp")); 338 temp_dir_ = base_dir_.path().Append(FPL("tmp"));
339 ASSERT_TRUE(base::CreateDirectory(temp_dir_)); 339 ASSERT_TRUE(base::CreateDirectory(temp_dir_));
340 } 340 }
341 341
342 base::FilePath FakeDriveServiceHelper::WriteToTempFile( 342 base::FilePath FakeDriveServiceHelper::WriteToTempFile(
343 const std::string& content) { 343 const std::string& content) {
344 base::FilePath temp_file; 344 base::FilePath temp_file;
345 EXPECT_TRUE(base::CreateTemporaryFileInDir(temp_dir_, &temp_file)); 345 EXPECT_TRUE(base::CreateTemporaryFileInDir(temp_dir_, &temp_file));
346 EXPECT_EQ(static_cast<int>(content.size()), 346 EXPECT_EQ(static_cast<int>(content.size()),
347 base::WriteFile(temp_file, content.data(), content.size())); 347 base::WriteFile(temp_file, content.data(), content.size()));
348 return temp_file; 348 return temp_file;
349 } 349 }
350 350
351 } // namespace drive_backend 351 } // namespace drive_backend
352 } // namespace sync_file_system 352 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698