Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: chrome/browser/chromeos/file_system_provider/provided_file_system.cc

Issue 210803003: [fsp] Decouple file_service_provider::Service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed more comments. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/provided_file_system.h" 5 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h"
6 6
7 #include "base/files/file.h"
8 #include "base/values.h"
9 #include "chrome/browser/chromeos/file_system_provider/request_manager.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/extensions/api/file_system_provider.h"
12 #include "extensions/browser/event_router.h"
13
7 namespace chromeos { 14 namespace chromeos {
8 namespace file_system_provider { 15 namespace file_system_provider {
16 namespace {
17
18 // Utility function, creates values to be passed to request events. These values
19 // can be extended by additional fields.
20 scoped_ptr<base::ListValue> CreateRequestValues(int file_system_id,
21 int request_id) {
22 scoped_ptr<base::ListValue> values(new base::ListValue());
23 values->AppendInteger(file_system_id);
24 values->AppendInteger(request_id);
25 return values.Pass();
26 }
27
28 // Forwards the success callback to the status callback. Ignores arguments,
29 // since unmount request does not provide arguments.
30 void OnRequestUnmountSuccess(
31 const fileapi::AsyncFileUtil::StatusCallback& callback,
32 scoped_ptr<base::DictionaryValue> /* result */,
33 bool /* has_next */) {
34 callback.Run(base::File::FILE_OK);
35 }
36
37 } // namespace
9 38
10 ProvidedFileSystem::ProvidedFileSystem() {} 39 ProvidedFileSystem::ProvidedFileSystem() {}
11 40
12 ProvidedFileSystem::ProvidedFileSystem(const std::string& extension_id, 41 ProvidedFileSystem::ProvidedFileSystem(
13 int file_system_id, 42 extensions::EventRouter* event_router,
14 const std::string& file_system_name, 43 RequestManager* request_manager,
15 const base::FilePath& mount_path) 44 const ProvidedFileSystemInfo& file_system_info)
16 : extension_id_(extension_id), 45 : event_router_(event_router),
17 file_system_id_(file_system_id), 46 request_manager_(request_manager),
18 file_system_name_(file_system_name), 47 file_system_info_(file_system_info) {}
19 mount_path_(mount_path) {}
20 48
21 ProvidedFileSystem::~ProvidedFileSystem() {} 49 ProvidedFileSystem::~ProvidedFileSystem() {}
22 50
51 bool ProvidedFileSystem::RequestUnmount(
52 const fileapi::AsyncFileUtil::StatusCallback& callback) {
53 int request_id = request_manager_->CreateRequest(
54 file_system_info_.extension_id(),
55 file_system_info_.file_system_id(),
56 base::Bind(&OnRequestUnmountSuccess, callback),
57 callback);
58
59 if (!request_id)
60 return false;
61
62 scoped_ptr<base::ListValue> values(
63 CreateRequestValues(file_system_info_.file_system_id(), request_id));
64
65 event_router_->DispatchEventToExtension(
66 file_system_info_.extension_id(),
67 make_scoped_ptr(new extensions::Event(
68 extensions::api::file_system_provider::OnUnmountRequested::kEventName,
69 values.Pass())));
70
71 return true;
72 }
73
74 const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const {
75 return file_system_info_;
76 }
77
23 } // namespace file_system_provider 78 } // namespace file_system_provider
24 } // namespace chromeos 79 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698