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

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

Issue 379743003: [fsp] Remove the create flag from the file opening operation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/operations/open_file.h" 5 #include "chrome/browser/chromeos/file_system_provider/operations/open_file.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 OpenFile::OpenFile( 16 OpenFile::OpenFile(
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& file_path, 19 const base::FilePath& file_path,
20 ProvidedFileSystemInterface::OpenFileMode mode, 20 ProvidedFileSystemInterface::OpenFileMode mode,
21 bool create,
22 const ProvidedFileSystemInterface::OpenFileCallback& callback) 21 const ProvidedFileSystemInterface::OpenFileCallback& callback)
23 : Operation(event_router, file_system_info), 22 : Operation(event_router, file_system_info),
24 file_path_(file_path), 23 file_path_(file_path),
25 mode_(mode), 24 mode_(mode),
26 create_(create),
27 callback_(callback) { 25 callback_(callback) {
28 } 26 }
29 27
30 OpenFile::~OpenFile() { 28 OpenFile::~OpenFile() {
31 } 29 }
32 30
33 bool OpenFile::Execute(int request_id) { 31 bool OpenFile::Execute(int request_id) {
34 scoped_ptr<base::DictionaryValue> values(new base::DictionaryValue); 32 scoped_ptr<base::DictionaryValue> values(new base::DictionaryValue);
35 values->SetString("filePath", file_path_.AsUTF8Unsafe()); 33 values->SetString("filePath", file_path_.AsUTF8Unsafe());
36 34
37 switch (mode_) { 35 switch (mode_) {
38 case ProvidedFileSystemInterface::OPEN_FILE_MODE_READ: 36 case ProvidedFileSystemInterface::OPEN_FILE_MODE_READ:
39 values->SetString( 37 values->SetString(
40 "mode", 38 "mode",
41 extensions::api::file_system_provider::ToString( 39 extensions::api::file_system_provider::ToString(
42 extensions::api::file_system_provider::OPEN_FILE_MODE_READ)); 40 extensions::api::file_system_provider::OPEN_FILE_MODE_READ));
43 break; 41 break;
44 case ProvidedFileSystemInterface::OPEN_FILE_MODE_WRITE: 42 case ProvidedFileSystemInterface::OPEN_FILE_MODE_WRITE:
45 values->SetString( 43 values->SetString(
46 "mode", 44 "mode",
47 extensions::api::file_system_provider::ToString( 45 extensions::api::file_system_provider::ToString(
48 extensions::api::file_system_provider::OPEN_FILE_MODE_WRITE)); 46 extensions::api::file_system_provider::OPEN_FILE_MODE_WRITE));
49 break; 47 break;
50 } 48 }
51 49
52 values->SetBoolean("create", create_);
53
54 return SendEvent( 50 return SendEvent(
55 request_id, 51 request_id,
56 extensions::api::file_system_provider::OnOpenFileRequested::kEventName, 52 extensions::api::file_system_provider::OnOpenFileRequested::kEventName,
57 values.Pass()); 53 values.Pass());
58 } 54 }
59 55
60 void OpenFile::OnSuccess(int request_id, 56 void OpenFile::OnSuccess(int request_id,
61 scoped_ptr<RequestValue> result, 57 scoped_ptr<RequestValue> result,
62 bool has_more) { 58 bool has_more) {
63 // File handle is the same as request id of the OpenFile operation. 59 // File handle is the same as request id of the OpenFile operation.
64 callback_.Run(request_id, base::File::FILE_OK); 60 callback_.Run(request_id, base::File::FILE_OK);
65 } 61 }
66 62
67 void OpenFile::OnError(int /* request_id */, 63 void OpenFile::OnError(int /* request_id */,
68 scoped_ptr<RequestValue> /* result */, 64 scoped_ptr<RequestValue> /* result */,
69 base::File::Error error) { 65 base::File::Error error) {
70 callback_.Run(0 /* file_handle */, error); 66 callback_.Run(0 /* file_handle */, error);
71 } 67 }
72 68
73 } // namespace operations 69 } // namespace operations
74 } // namespace file_system_provider 70 } // namespace file_system_provider
75 } // namespace chromeos 71 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698