OLD | NEW |
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/chromeos/file_system_provider/operations/open_file.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/open_file.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "chrome/common/extensions/api/file_system_provider.h" | 9 #include "chrome/common/extensions/api/file_system_provider.h" |
10 #include "chrome/common/extensions/api/file_system_provider_internal.h" | 10 #include "chrome/common/extensions/api/file_system_provider_internal.h" |
11 | 11 |
12 namespace chromeos { | 12 namespace chromeos { |
13 namespace file_system_provider { | 13 namespace file_system_provider { |
14 namespace operations { | 14 namespace operations { |
15 | 15 |
16 OpenFile::OpenFile(extensions::EventRouter* event_router, | 16 OpenFile::OpenFile( |
17 const ProvidedFileSystemInfo& file_system_info, | 17 extensions::EventRouter* event_router, |
18 const base::FilePath& file_path, | 18 const ProvidedFileSystemInfo& file_system_info, |
19 ProvidedFileSystemInterface::OpenFileMode mode, | 19 const base::FilePath& file_path, |
20 bool create, | 20 ProvidedFileSystemInterface::OpenFileMode mode, |
21 const fileapi::AsyncFileUtil::StatusCallback& callback) | 21 bool create, |
| 22 const ProvidedFileSystemInterface::OpenFileCallback& callback) |
22 : Operation(event_router, file_system_info), | 23 : Operation(event_router, file_system_info), |
23 file_path_(file_path), | 24 file_path_(file_path), |
24 mode_(mode), | 25 mode_(mode), |
25 create_(create), | 26 create_(create), |
26 callback_(callback) { | 27 callback_(callback) { |
27 } | 28 } |
28 | 29 |
29 OpenFile::~OpenFile() { | 30 OpenFile::~OpenFile() { |
30 } | 31 } |
31 | 32 |
(...skipping 13 matching lines...) Expand all Loading... |
45 } | 46 } |
46 | 47 |
47 values->AppendBoolean(create_); | 48 values->AppendBoolean(create_); |
48 | 49 |
49 return SendEvent( | 50 return SendEvent( |
50 request_id, | 51 request_id, |
51 extensions::api::file_system_provider::OnOpenFileRequested::kEventName, | 52 extensions::api::file_system_provider::OnOpenFileRequested::kEventName, |
52 values.Pass()); | 53 values.Pass()); |
53 } | 54 } |
54 | 55 |
55 void OpenFile::OnSuccess(int /* request_id */, | 56 void OpenFile::OnSuccess(int request_id, |
56 scoped_ptr<RequestValue> result, | 57 scoped_ptr<RequestValue> result, |
57 bool has_next) { | 58 bool has_next) { |
58 callback_.Run(base::File::FILE_OK); | 59 // File handle is the same as request id of the OpenFile operation. |
| 60 callback_.Run(request_id, base::File::FILE_OK); |
59 } | 61 } |
60 | 62 |
61 void OpenFile::OnError(int /* request_id */, base::File::Error error) { | 63 void OpenFile::OnError(int /* request_id */, base::File::Error error) { |
62 callback_.Run(error); | 64 callback_.Run(0 /* file_handle */, error); |
63 } | 65 } |
64 | 66 |
65 } // namespace operations | 67 } // namespace operations |
66 } // namespace file_system_provider | 68 } // namespace file_system_provider |
67 } // namespace chromeos | 69 } // namespace chromeos |
OLD | NEW |