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

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: 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/profiles/profile.h"
10 #include "chrome/common/extensions/api/file_system_provider.h"
11 #include "extensions/browser/event_router.h"
12
7 namespace chromeos { 13 namespace chromeos {
8 namespace file_system_provider { 14 namespace file_system_provider {
15 namespace {
16
17 // Utility function, creates values to be passed to request events. These values
18 // can be extended by additional fields.
19 scoped_ptr<base::ListValue> CreateRequestValues(int file_system_id,
20 int request_id) {
21 scoped_ptr<base::ListValue> values(new base::ListValue());
22 values->AppendInteger(file_system_id);
23 values->AppendInteger(request_id);
24 return values.Pass();
25 }
26
27 // Forwards the success callback to the status callback. Ignores arguments,
28 // since unmount reqiest does not provide arguments.
hashimoto 2014/03/26 03:03:01 nit: s/reqiest/request/?
mtomasz 2014/03/26 05:45:13 Done.
29 void OnRequestUnmountSuccess(
30 const fileapi::AsyncFileUtil::StatusCallback& callback,
31 scoped_ptr<base::DictionaryValue> /* result */,
32 bool /* has_next */) {
33 callback.Run(base::File::FILE_OK);
34 }
35
36 } // namespace
9 37
10 ProvidedFileSystem::ProvidedFileSystem() {} 38 ProvidedFileSystem::ProvidedFileSystem() {}
11 39
12 ProvidedFileSystem::ProvidedFileSystem(const std::string& extension_id, 40 ProvidedFileSystem::ProvidedFileSystem(
13 int file_system_id, 41 extensions::EventRouter* event_router,
14 const std::string& file_system_name, 42 RequestManager* request_manager,
15 const base::FilePath& mount_path) 43 const ProvidedFileSystemInfo& file_system_info)
16 : extension_id_(extension_id), 44 : event_router_(event_router),
17 file_system_id_(file_system_id), 45 request_manager_(request_manager),
18 file_system_name_(file_system_name), 46 file_system_info_(file_system_info) {}
19 mount_path_(mount_path) {}
20 47
21 ProvidedFileSystem::~ProvidedFileSystem() {} 48 ProvidedFileSystem::~ProvidedFileSystem() {}
22 49
50 bool ProvidedFileSystem::RequestUnmount(
51 const fileapi::AsyncFileUtil::StatusCallback& callback) {
52 int request_id = request_manager_->CreateRequest(
53 file_system_info_.extension_id(),
54 file_system_info_.file_system_id(),
55 base::Bind(&OnRequestUnmountSuccess, callback),
56 callback);
57
58 if (!request_id)
59 return false;
60
61 scoped_ptr<base::ListValue> values(
62 CreateRequestValues(file_system_info_.file_system_id(), request_id));
63
64 event_router_->DispatchEventToExtension(
65 file_system_info_.extension_id(),
66 make_scoped_ptr(new extensions::Event(
67 extensions::api::file_system_provider::OnUnmountRequested::kEventName,
68 values.Pass())));
69
70 return true;
71 }
72
73 const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const {
74 return file_system_info_;
75 }
76
23 } // namespace file_system_provider 77 } // namespace file_system_provider
24 } // namespace chromeos 78 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698