OLD | NEW |
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 <errno.h> | 5 #include <errno.h> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 // RefCountedThreadSafe, and a place where we can fetch results from various | 1207 // RefCountedThreadSafe, and a place where we can fetch results from various |
1208 // operations. | 1208 // operations. |
1209 class CallbackHelper | 1209 class CallbackHelper |
1210 : public base::RefCountedThreadSafe<CallbackHelper> { | 1210 : public base::RefCountedThreadSafe<CallbackHelper> { |
1211 public: | 1211 public: |
1212 CallbackHelper() | 1212 CallbackHelper() |
1213 : last_error_(base::PLATFORM_FILE_OK), | 1213 : last_error_(base::PLATFORM_FILE_OK), |
1214 quota_bytes_total_(0), | 1214 quota_bytes_total_(0), |
1215 quota_bytes_used_(0), | 1215 quota_bytes_used_(0), |
1216 file_proto_(NULL) {} | 1216 file_proto_(NULL) {} |
1217 virtual ~CallbackHelper() {} | |
1218 | 1217 |
1219 virtual void GetFileCallback(base::PlatformFileError error, | 1218 virtual void GetFileCallback(base::PlatformFileError error, |
1220 const FilePath& file_path, | 1219 const FilePath& file_path, |
1221 const std::string& mime_type, | 1220 const std::string& mime_type, |
1222 GDataFileType file_type) { | 1221 GDataFileType file_type) { |
1223 last_error_ = error; | 1222 last_error_ = error; |
1224 download_path_ = file_path; | 1223 download_path_ = file_path; |
1225 mime_type_ = mime_type; | 1224 mime_type_ = mime_type; |
1226 file_type_ = file_type; | 1225 file_type_ = file_type; |
1227 } | 1226 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 base::PlatformFileError last_error_; | 1277 base::PlatformFileError last_error_; |
1279 FilePath download_path_; | 1278 FilePath download_path_; |
1280 FilePath opened_file_path_; | 1279 FilePath opened_file_path_; |
1281 std::string mime_type_; | 1280 std::string mime_type_; |
1282 GDataFileType file_type_; | 1281 GDataFileType file_type_; |
1283 int64 quota_bytes_total_; | 1282 int64 quota_bytes_total_; |
1284 int64 quota_bytes_used_; | 1283 int64 quota_bytes_used_; |
1285 scoped_ptr<GDataEntryProto> entry_proto_; | 1284 scoped_ptr<GDataEntryProto> entry_proto_; |
1286 scoped_ptr<GDataFileProto> file_proto_; | 1285 scoped_ptr<GDataFileProto> file_proto_; |
1287 scoped_ptr<GDataDirectoryProto> directory_proto_; | 1286 scoped_ptr<GDataDirectoryProto> directory_proto_; |
| 1287 |
| 1288 protected: |
| 1289 virtual ~CallbackHelper() {} |
| 1290 |
| 1291 private: |
| 1292 friend class base::RefCountedThreadSafe<CallbackHelper>; |
1288 }; | 1293 }; |
1289 | 1294 |
1290 MessageLoopForUI message_loop_; | 1295 MessageLoopForUI message_loop_; |
1291 // The order of the test threads is important, do not change the order. | 1296 // The order of the test threads is important, do not change the order. |
1292 // See also content/browser/browser_thread_imple.cc. | 1297 // See also content/browser/browser_thread_imple.cc. |
1293 content::TestBrowserThread ui_thread_; | 1298 content::TestBrowserThread ui_thread_; |
1294 content::TestBrowserThread io_thread_; | 1299 content::TestBrowserThread io_thread_; |
1295 const base::SequencedWorkerPool::SequenceToken sequence_token_; | 1300 const base::SequencedWorkerPool::SequenceToken sequence_token_; |
1296 scoped_ptr<TestingProfile> profile_; | 1301 scoped_ptr<TestingProfile> profile_; |
1297 scoped_refptr<CallbackHelper> callback_helper_; | 1302 scoped_refptr<CallbackHelper> callback_helper_; |
(...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3520 | 3525 |
3521 // Try to close the same file twice. | 3526 // Try to close the same file twice. |
3522 file_system_->CloseFile(kFileInRoot, close_file_callback); | 3527 file_system_->CloseFile(kFileInRoot, close_file_callback); |
3523 message_loop_.Run(); | 3528 message_loop_.Run(); |
3524 | 3529 |
3525 // It must fail. | 3530 // It must fail. |
3526 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 3531 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
3527 } | 3532 } |
3528 | 3533 |
3529 } // namespace gdata | 3534 } // namespace gdata |
OLD | NEW |