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/create_file.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/create_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 CreateFile::CreateFile(extensions::EventRouter* event_router, | 16 CreateFile::CreateFile(extensions::EventRouter* event_router, |
17 const ProvidedFileSystemInfo& file_system_info, | 17 const ProvidedFileSystemInfo& file_system_info, |
18 const base::FilePath& file_path, | 18 const base::FilePath& file_path, |
19 const storage::AsyncFileUtil::StatusCallback& callback) | 19 const storage::AsyncFileUtil::StatusCallback& callback) |
20 : Operation(event_router, file_system_info), | 20 : Operation(event_router, file_system_info), |
21 file_path_(file_path), | 21 file_path_(file_path), |
22 callback_(callback) { | 22 callback_(callback) { |
23 } | 23 } |
24 | 24 |
25 CreateFile::~CreateFile() { | 25 CreateFile::~CreateFile() { |
26 } | 26 } |
27 | 27 |
28 bool CreateFile::Execute(int request_id) { | 28 bool CreateFile::Execute(int request_id) { |
| 29 using extensions::api::file_system_provider::CreateFileRequestedOptions; |
| 30 |
29 if (!file_system_info_.writable()) | 31 if (!file_system_info_.writable()) |
30 return false; | 32 return false; |
31 | 33 |
32 scoped_ptr<base::DictionaryValue> values(new base::DictionaryValue); | 34 CreateFileRequestedOptions options; |
33 values->SetString("filePath", file_path_.AsUTF8Unsafe()); | 35 options.file_system_id = file_system_info_.file_system_id(); |
| 36 options.request_id = request_id; |
| 37 options.file_path = file_path_.AsUTF8Unsafe(); |
34 | 38 |
35 return SendEvent( | 39 return SendEvent( |
36 request_id, | 40 request_id, |
37 extensions::api::file_system_provider::OnCreateFileRequested::kEventName, | 41 extensions::api::file_system_provider::OnCreateFileRequested::kEventName, |
38 values.Pass()); | 42 extensions::api::file_system_provider::OnCreateFileRequested::Create( |
| 43 options)); |
39 } | 44 } |
40 | 45 |
41 void CreateFile::OnSuccess(int /* request_id */, | 46 void CreateFile::OnSuccess(int /* request_id */, |
42 scoped_ptr<RequestValue> /* result */, | 47 scoped_ptr<RequestValue> /* result */, |
43 bool has_more) { | 48 bool has_more) { |
44 callback_.Run(base::File::FILE_OK); | 49 callback_.Run(base::File::FILE_OK); |
45 } | 50 } |
46 | 51 |
47 void CreateFile::OnError(int /* request_id */, | 52 void CreateFile::OnError(int /* request_id */, |
48 scoped_ptr<RequestValue> /* result */, | 53 scoped_ptr<RequestValue> /* result */, |
49 base::File::Error error) { | 54 base::File::Error error) { |
50 callback_.Run(error); | 55 callback_.Run(error); |
51 } | 56 } |
52 | 57 |
53 } // namespace operations | 58 } // namespace operations |
54 } // namespace file_system_provider | 59 } // namespace file_system_provider |
55 } // namespace chromeos | 60 } // namespace chromeos |
OLD | NEW |