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_directo
ry.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/create_directo
ry.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 CreateDirectory::CreateDirectory( | 16 template <int source> |
17 extensions::EventRouter* event_router, | 17 CreateDirectory<source>::CreateDirectory( |
| 18 typename Operation<source>::EventRouterType* event_router, |
18 const ProvidedFileSystemInfo& file_system_info, | 19 const ProvidedFileSystemInfo& file_system_info, |
19 const base::FilePath& directory_path, | 20 const base::FilePath& directory_path, |
20 bool recursive, | 21 bool recursive, |
21 const storage::AsyncFileUtil::StatusCallback& callback) | 22 const storage::AsyncFileUtil::StatusCallback& callback) |
22 : Operation(event_router, file_system_info), | 23 : Operation<source>(event_router, file_system_info), |
23 directory_path_(directory_path), | 24 directory_path_(directory_path), |
24 recursive_(recursive), | 25 recursive_(recursive), |
25 callback_(callback) { | 26 callback_(callback) { |
26 } | 27 } |
27 | 28 |
28 CreateDirectory::~CreateDirectory() { | 29 template <int source> |
| 30 CreateDirectory<source>::~CreateDirectory() { |
29 } | 31 } |
30 | 32 |
31 bool CreateDirectory::Execute(int request_id) { | 33 template <int source> |
| 34 bool CreateDirectory<source>::Execute(int request_id) { |
32 using extensions::api::file_system_provider::CreateDirectoryRequestedOptions; | 35 using extensions::api::file_system_provider::CreateDirectoryRequestedOptions; |
33 | 36 |
34 if (!file_system_info_.writable()) | 37 if (!this->file_system_info_.writable()) |
35 return false; | 38 return false; |
36 | 39 |
37 CreateDirectoryRequestedOptions options; | 40 CreateDirectoryRequestedOptions options; |
38 options.file_system_id = file_system_info_.file_system_id(); | 41 options.file_system_id = this->file_system_info_.file_system_id(); |
39 options.request_id = request_id; | 42 options.request_id = request_id; |
40 options.directory_path = directory_path_.AsUTF8Unsafe(); | 43 options.directory_path = directory_path_.AsUTF8Unsafe(); |
41 options.recursive = recursive_; | 44 options.recursive = recursive_; |
42 | 45 |
43 return SendEvent( | 46 return this->SendEvent( |
44 request_id, | 47 request_id, extensions::api::file_system_provider:: |
45 extensions::api::file_system_provider::OnCreateDirectoryRequested:: | 48 OnCreateDirectoryRequested::kEventName, |
46 kEventName, | |
47 extensions::api::file_system_provider::OnCreateDirectoryRequested::Create( | 49 extensions::api::file_system_provider::OnCreateDirectoryRequested::Create( |
48 options)); | 50 options)); |
49 } | 51 } |
50 | 52 |
51 void CreateDirectory::OnSuccess(int /* request_id */, | 53 template <int source> |
52 scoped_ptr<RequestValue> /* result */, | 54 void CreateDirectory<source>::OnSuccess(int /* request_id */, |
53 bool has_more) { | 55 scoped_ptr<RequestValue> /* result */, |
| 56 bool has_more) { |
54 callback_.Run(base::File::FILE_OK); | 57 callback_.Run(base::File::FILE_OK); |
55 } | 58 } |
56 | 59 |
57 void CreateDirectory::OnError(int /* request_id */, | 60 template <int source> |
58 scoped_ptr<RequestValue> /* result */, | 61 void CreateDirectory<source>::OnError(int /* request_id */, |
59 base::File::Error error) { | 62 scoped_ptr<RequestValue> /* result */, |
| 63 base::File::Error error) { |
60 callback_.Run(error); | 64 callback_.Run(error); |
61 } | 65 } |
62 | 66 |
| 67 template class CreateDirectory<Source_Type::extension>; |
| 68 template class CreateDirectory<Source_Type::plugin>; |
| 69 |
63 } // namespace operations | 70 } // namespace operations |
64 } // namespace file_system_provider | 71 } // namespace file_system_provider |
65 } // namespace chromeos | 72 } // namespace chromeos |
OLD | NEW |