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

Side by Side Diff: chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc

Issue 1055183003: Add a data source field for volumes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a typo. Created 5 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/extensions/file_system_provider/file_system_pr ovider_api.h" 5 #include "chrome/browser/chromeos/extensions/file_system_provider/file_system_pr ovider_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 scoped_ptr<ProvidedFileSystemObserver::Changes> ParseChanges( 63 scoped_ptr<ProvidedFileSystemObserver::Changes> ParseChanges(
64 const IDLChanges& changes) { 64 const IDLChanges& changes) {
65 scoped_ptr<ProvidedFileSystemObserver::Changes> results( 65 scoped_ptr<ProvidedFileSystemObserver::Changes> results(
66 new ProvidedFileSystemObserver::Changes); 66 new ProvidedFileSystemObserver::Changes);
67 for (const auto& change : changes) { 67 for (const auto& change : changes) {
68 results->push_back(ParseChange(*change)); 68 results->push_back(ParseChange(*change));
69 } 69 }
70 return results; 70 return results;
71 } 71 }
72 72
73 // Converts the file system source from the IDL type to a native type.
74 chromeos::file_system_provider::Source ParseSource(
75 const api::file_system_provider::FileSystemSource& source) {
76 switch (source) {
77 case api::file_system_provider::FILE_SYSTEM_SOURCE_FILE:
78 return chromeos::file_system_provider::SOURCE_FILE;
79 case api::file_system_provider::FILE_SYSTEM_SOURCE_DEVICE:
80 return chromeos::file_system_provider::SOURCE_DEVICE;
81 case api::file_system_provider::FILE_SYSTEM_SOURCE_NETWORK:
82 return chromeos::file_system_provider::SOURCE_NETWORK;
83 case api::file_system_provider::FILE_SYSTEM_SOURCE_NONE:
84 return chromeos::file_system_provider::SOURCE_UNKNOWN;
85 }
86 return chromeos::file_system_provider::SOURCE_UNKNOWN;
87 }
88
73 // Fills the IDL's FileSystemInfo with FSP's ProvidedFileSystemInfo and 89 // Fills the IDL's FileSystemInfo with FSP's ProvidedFileSystemInfo and
74 // Watchers. 90 // Watchers.
75 void FillFileSystemInfo(const ProvidedFileSystemInfo& file_system_info, 91 void FillFileSystemInfo(const ProvidedFileSystemInfo& file_system_info,
76 const Watchers& watchers, 92 const Watchers& watchers,
77 const OpenedFiles& opened_files, 93 const OpenedFiles& opened_files,
78 api::file_system_provider::FileSystemInfo* output) { 94 api::file_system_provider::FileSystemInfo* output) {
79 using api::file_system_provider::Watcher; 95 using api::file_system_provider::Watcher;
80 using api::file_system_provider::OpenedFile; 96 using api::file_system_provider::OpenedFile;
81 97
82 output->file_system_id = file_system_info.file_system_id(); 98 output->file_system_id = file_system_info.file_system_id();
83 output->display_name = file_system_info.display_name(); 99 output->display_name = file_system_info.display_name();
84 output->writable = file_system_info.writable(); 100 output->writable = file_system_info.writable();
85 output->opened_files_limit = file_system_info.opened_files_limit(); 101 output->opened_files_limit = file_system_info.opened_files_limit();
102 switch (file_system_info.source()) {
103 case chromeos::file_system_provider::SOURCE_FILE:
104 output->source = api::file_system_provider::FILE_SYSTEM_SOURCE_FILE;
105 break;
106 case chromeos::file_system_provider::SOURCE_DEVICE:
107 output->source = api::file_system_provider::FILE_SYSTEM_SOURCE_DEVICE;
108 break;
109 case chromeos::file_system_provider::SOURCE_NETWORK:
110 output->source = api::file_system_provider::FILE_SYSTEM_SOURCE_NETWORK;
111 break;
112 case chromeos::file_system_provider::SOURCE_UNKNOWN:
113 output->source = api::file_system_provider::FILE_SYSTEM_SOURCE_NONE;
114 break;
115 }
86 116
87 std::vector<linked_ptr<Watcher>> watcher_items; 117 std::vector<linked_ptr<Watcher>> watcher_items;
88 for (const auto& watcher : watchers) { 118 for (const auto& watcher : watchers) {
89 const linked_ptr<Watcher> watcher_item(new Watcher); 119 const linked_ptr<Watcher> watcher_item(new Watcher);
90 watcher_item->entry_path = watcher.second.entry_path.value(); 120 watcher_item->entry_path = watcher.second.entry_path.value();
91 watcher_item->recursive = watcher.second.recursive; 121 watcher_item->recursive = watcher.second.recursive;
92 if (!watcher.second.last_tag.empty()) 122 if (!watcher.second.last_tag.empty())
93 watcher_item->last_tag.reset(new std::string(watcher.second.last_tag)); 123 watcher_item->last_tag.reset(new std::string(watcher.second.last_tag));
94 watcher_items.push_back(watcher_item); 124 watcher_items.push_back(watcher_item);
95 } 125 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 DCHECK(service); 175 DCHECK(service);
146 176
147 MountOptions options; 177 MountOptions options;
148 options.file_system_id = params->options.file_system_id; 178 options.file_system_id = params->options.file_system_id;
149 options.display_name = params->options.display_name; 179 options.display_name = params->options.display_name;
150 options.writable = params->options.writable; 180 options.writable = params->options.writable;
151 options.opened_files_limit = params->options.opened_files_limit.get() 181 options.opened_files_limit = params->options.opened_files_limit.get()
152 ? *params->options.opened_files_limit.get() 182 ? *params->options.opened_files_limit.get()
153 : 0; 183 : 0;
154 options.supports_notify_tag = params->options.supports_notify_tag; 184 options.supports_notify_tag = params->options.supports_notify_tag;
185 options.source = ParseSource(params->options.source);
155 186
156 const base::File::Error result = 187 const base::File::Error result =
157 service->MountFileSystem(extension_id(), options); 188 service->MountFileSystem(extension_id(), options);
158 if (result != base::File::FILE_OK) { 189 if (result != base::File::FILE_OK) {
159 SetError(FileErrorToString(result)); 190 SetError(FileErrorToString(result));
160 return false; 191 return false;
161 } 192 }
162 193
163 return true; 194 return true;
164 } 195 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 using api::file_system_provider_internal::OperationRequestedError::Params; 369 using api::file_system_provider_internal::OperationRequestedError::Params;
339 scoped_ptr<Params> params(Params::Create(*args_)); 370 scoped_ptr<Params> params(Params::Create(*args_));
340 EXTENSION_FUNCTION_VALIDATE(params); 371 EXTENSION_FUNCTION_VALIDATE(params);
341 372
342 const base::File::Error error = ProviderErrorToFileError(params->error); 373 const base::File::Error error = ProviderErrorToFileError(params->error);
343 return RejectRequest(RequestValue::CreateForOperationError(params.Pass()), 374 return RejectRequest(RequestValue::CreateForOperationError(params.Pass()),
344 error); 375 error);
345 } 376 }
346 377
347 } // namespace extensions 378 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698