| OLD | NEW |
| 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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 SetError(FileErrorToString(base::File::FILE_ERROR_INVALID_OPERATION)); | 80 SetError(FileErrorToString(base::File::FILE_ERROR_INVALID_OPERATION)); |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 | 83 |
| 84 // It's an error if the display name is empty. | 84 // It's an error if the display name is empty. |
| 85 if (params->options.display_name.empty()) { | 85 if (params->options.display_name.empty()) { |
| 86 SetError(FileErrorToString(base::File::FILE_ERROR_INVALID_OPERATION)); | 86 SetError(FileErrorToString(base::File::FILE_ERROR_INVALID_OPERATION)); |
| 87 return false; | 87 return false; |
| 88 } | 88 } |
| 89 | 89 |
| 90 // If the opened files limit is set, then it must be larger or equal than 0. |
| 91 if (params->options.opened_files_limit.get() && |
| 92 *params->options.opened_files_limit.get() < 0) { |
| 93 SetError(FileErrorToString(base::File::FILE_ERROR_INVALID_OPERATION)); |
| 94 return false; |
| 95 } |
| 96 |
| 90 Service* const service = Service::Get(GetProfile()); | 97 Service* const service = Service::Get(GetProfile()); |
| 91 DCHECK(service); | 98 DCHECK(service); |
| 92 | 99 |
| 93 MountOptions options; | 100 MountOptions options; |
| 94 options.file_system_id = params->options.file_system_id; | 101 options.file_system_id = params->options.file_system_id; |
| 95 options.display_name = params->options.display_name; | 102 options.display_name = params->options.display_name; |
| 96 options.writable = params->options.writable; | 103 options.writable = params->options.writable; |
| 104 options.opened_files_limit = params->options.opened_files_limit.get() |
| 105 ? *params->options.opened_files_limit.get() |
| 106 : 0; |
| 97 options.supports_notify_tag = params->options.supports_notify_tag; | 107 options.supports_notify_tag = params->options.supports_notify_tag; |
| 98 | 108 |
| 99 const base::File::Error result = | 109 const base::File::Error result = |
| 100 service->MountFileSystem(extension_id(), options); | 110 service->MountFileSystem(extension_id(), options); |
| 101 if (result != base::File::FILE_OK) { | 111 if (result != base::File::FILE_OK) { |
| 102 SetError(FileErrorToString(result)); | 112 SetError(FileErrorToString(result)); |
| 103 return false; | 113 return false; |
| 104 } | 114 } |
| 105 | 115 |
| 106 return true; | 116 return true; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 using api::file_system_provider_internal::OperationRequestedError::Params; | 282 using api::file_system_provider_internal::OperationRequestedError::Params; |
| 273 scoped_ptr<Params> params(Params::Create(*args_)); | 283 scoped_ptr<Params> params(Params::Create(*args_)); |
| 274 EXTENSION_FUNCTION_VALIDATE(params); | 284 EXTENSION_FUNCTION_VALIDATE(params); |
| 275 | 285 |
| 276 const base::File::Error error = ProviderErrorToFileError(params->error); | 286 const base::File::Error error = ProviderErrorToFileError(params->error); |
| 277 return RejectRequest(RequestValue::CreateForOperationError(params.Pass()), | 287 return RejectRequest(RequestValue::CreateForOperationError(params.Pass()), |
| 278 error); | 288 error); |
| 279 } | 289 } |
| 280 | 290 |
| 281 } // namespace extensions | 291 } // namespace extensions |
| OLD | NEW |