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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/file_system_provider/operations/create_file.h"
9 #include "chrome/common/extensions/api/file_system_provider.h"
10 #include "chrome/common/extensions/api/file_system_provider_internal.h"
13 namespace file_system_provider
{
14 namespace operations
{
16 CreateFile::CreateFile(extensions::EventRouter
* event_router
,
17 const ProvidedFileSystemInfo
& file_system_info
,
18 const base::FilePath
& file_path
,
19 const storage::AsyncFileUtil::StatusCallback
& callback
)
20 : Operation(event_router
, file_system_info
),
21 file_path_(file_path
),
25 CreateFile::~CreateFile() {
28 bool CreateFile::Execute(int request_id
) {
29 using extensions::api::file_system_provider::CreateFileRequestedOptions
;
31 if (!file_system_info_
.writable())
34 CreateFileRequestedOptions options
;
35 options
.file_system_id
= file_system_info_
.file_system_id();
36 options
.request_id
= request_id
;
37 options
.file_path
= file_path_
.AsUTF8Unsafe();
41 extensions::events::FILE_SYSTEM_PROVIDER_ON_CREATE_FILE_REQUESTED
,
42 extensions::api::file_system_provider::OnCreateFileRequested::kEventName
,
43 extensions::api::file_system_provider::OnCreateFileRequested::Create(
47 void CreateFile::OnSuccess(int /* request_id */,
48 scoped_ptr
<RequestValue
> /* result */,
50 callback_
.Run(base::File::FILE_OK
);
53 void CreateFile::OnError(int /* request_id */,
54 scoped_ptr
<RequestValue
> /* result */,
55 base::File::Error error
) {
59 } // namespace operations
60 } // namespace file_system_provider
61 } // namespace chromeos