1 // Copyright 2015 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.
4
5 #include "chrome/browser/chromeos/file_system_provider/operations/configure.h"
6
7 #include "base/values.h"
8 #include "chrome/common/extensions/api/file_system_provider.h"
9
10 namespace chromeos {
11 namespace file_system_provider {
12 namespace operations {
13
Configure(extensions::EventRouter * event_router,const ProvidedFileSystemInfo & file_system_info,storage::AsyncFileUtil::StatusCallback callback)14 Configure::Configure(extensions::EventRouter* event_router,
15 const ProvidedFileSystemInfo& file_system_info,
16 storage::AsyncFileUtil::StatusCallback callback)
17 : Operation(event_router, file_system_info),
18 callback_(std::move(callback)) {}
19
~Configure()20 Configure::~Configure() {
21 }
22
Execute(int request_id)23 bool Configure::Execute(int request_id) {
24 using extensions::api::file_system_provider::ConfigureRequestedOptions;
25
26 ConfigureRequestedOptions options;
27 options.file_system_id = file_system_info_.file_system_id();
28 options.request_id = request_id;
29
30 return SendEvent(
31 request_id,
32 extensions::events::FILE_SYSTEM_PROVIDER_ON_CONFIGURE_REQUESTED,
33 extensions::api::file_system_provider::OnConfigureRequested::kEventName,
34 extensions::api::file_system_provider::OnConfigureRequested::Create(
35 options));
36 }
37
OnSuccess(int,std::unique_ptr<RequestValue>,bool)38 void Configure::OnSuccess(int /* request_id */,
39 std::unique_ptr<RequestValue> /* result */,
40 bool /* has_more */) {
41 DCHECK(callback_);
42 std::move(callback_).Run(base::File::FILE_OK);
43 }
44
OnError(int,std::unique_ptr<RequestValue>,base::File::Error error)45 void Configure::OnError(int /* request_id */,
46 std::unique_ptr<RequestValue> /* result */,
47 base::File::Error error) {
48 DCHECK(callback_);
49 std::move(callback_).Run(error);
50 }
51
52 } // namespace operations
53 } // namespace file_system_provider
54 } // namespace chromeos
55