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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/operations/observe_directory.cc

Issue 625463002: [fsp] Add support for observing entries and notifying about changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 2 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
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/operations/create_directo ry.h" 5 #include "chrome/browser/chromeos/file_system_provider/operations/observe_direct ory.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 ObserveDirectory::ObserveDirectory(
17 extensions::EventRouter* event_router, 17 extensions::EventRouter* event_router,
18 const ProvidedFileSystemInfo& file_system_info, 18 const ProvidedFileSystemInfo& file_system_info,
19 const base::FilePath& directory_path, 19 const base::FilePath& directory_path,
20 bool recursive, 20 bool recursive,
21 const storage::AsyncFileUtil::StatusCallback& callback) 21 const storage::AsyncFileUtil::StatusCallback& callback)
22 : Operation(event_router, file_system_info), 22 : Operation(event_router, file_system_info),
23 directory_path_(directory_path), 23 directory_path_(directory_path),
24 recursive_(recursive), 24 recursive_(recursive),
25 callback_(callback) { 25 callback_(callback) {
26 } 26 }
27 27
28 CreateDirectory::~CreateDirectory() { 28 ObserveDirectory::~ObserveDirectory() {
29 } 29 }
30 30
31 bool CreateDirectory::Execute(int request_id) { 31 bool ObserveDirectory::Execute(int request_id) {
32 using extensions::api::file_system_provider::CreateDirectoryRequestedOptions; 32 using extensions::api::file_system_provider::ObserveDirectoryRequestedOptions;
33 33
34 if (!file_system_info_.writable()) 34 ObserveDirectoryRequestedOptions options;
35 return false;
36
37 CreateDirectoryRequestedOptions options;
38 options.file_system_id = file_system_info_.file_system_id(); 35 options.file_system_id = file_system_info_.file_system_id();
39 options.request_id = request_id; 36 options.request_id = request_id;
40 options.directory_path = directory_path_.AsUTF8Unsafe(); 37 options.directory_path = directory_path_.AsUTF8Unsafe();
41 options.recursive = recursive_; 38 options.recursive = recursive_;
42 39
43 return SendEvent( 40 return SendEvent(request_id,
44 request_id, 41 extensions::api::file_system_provider::
45 extensions::api::file_system_provider::OnCreateDirectoryRequested:: 42 OnObserveDirectoryRequested::kEventName,
46 kEventName, 43 extensions::api::file_system_provider::
47 extensions::api::file_system_provider::OnCreateDirectoryRequested::Create( 44 OnObserveDirectoryRequested::Create(options));
48 options));
49 } 45 }
50 46
51 void CreateDirectory::OnSuccess(int /* request_id */, 47 void ObserveDirectory::OnSuccess(int /* request_id */,
52 scoped_ptr<RequestValue> /* result */, 48 scoped_ptr<RequestValue> /* result */,
53 bool has_more) { 49 bool has_more) {
54 callback_.Run(base::File::FILE_OK); 50 callback_.Run(base::File::FILE_OK);
55 } 51 }
56 52
57 void CreateDirectory::OnError(int /* request_id */, 53 void ObserveDirectory::OnError(int /* request_id */,
58 scoped_ptr<RequestValue> /* result */, 54 scoped_ptr<RequestValue> /* result */,
59 base::File::Error error) { 55 base::File::Error error) {
60 callback_.Run(error); 56 callback_.Run(error);
61 } 57 }
62 58
63 } // namespace operations 59 } // namespace operations
64 } // namespace file_system_provider 60 } // namespace file_system_provider
65 } // namespace chromeos 61 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698