Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_SYSTEM_PROVIDER_PROVIDER_FUNCTIO N_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_SYSTEM_PROVIDER_PROVIDER_FUNCTIO N_H_ | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/files/file.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/values.h" | |
|
hashimoto
2014/05/01 09:20:12
nit: "class DictionaryValue;" is enough?
mtomasz
2014/05/02 01:26:22
Done.
| |
| 12 #include "chrome/browser/extensions/chrome_extension_function.h" | |
| 13 #include "chrome/common/extensions/api/file_system_provider.h" | |
| 14 | |
| 15 namespace chromeos { | |
| 16 namespace file_system_provider { | |
| 17 class RequestValue; | |
| 18 } // file_system_provider | |
| 19 } // chromeos | |
| 20 | |
| 21 namespace extensions { | |
| 22 | |
| 23 // Error names from | |
| 24 // http://www.w3.org/TR/file-system-api/#errors-and-exceptions | |
| 25 extern const char kNotFoundErrorName[]; | |
| 26 extern const char kSecurityErrorName[]; | |
| 27 | |
| 28 // Error messages. | |
| 29 extern const char kEmptyNameErrorMessage[]; | |
| 30 extern const char kMountFailedErrorMessage[]; | |
| 31 extern const char kUnmountFailedErrorMessage[]; | |
| 32 extern const char kResponseFailedErrorMessage[]; | |
| 33 | |
| 34 // Creates a dictionary, which looks like a DOMError. The returned dictionary | |
| 35 // will be converted to a real DOMError object in | |
| 36 // file_system_provier_custom_bindings.js. | |
| 37 base::DictionaryValue* CreateError(const std::string& name, | |
| 38 const std::string& message); | |
| 39 | |
| 40 // Converts ProviderError to base::File::Error. This could be redundant, if it | |
| 41 // was possible to create DOMError instances in Javascript easily. | |
| 42 base::File::Error ProviderErrorToFileError( | |
| 43 api::file_system_provider::ProviderError error); | |
| 44 | |
| 45 class FileSystemProviderInternalFunction : public ChromeSyncExtensionFunction { | |
|
hashimoto
2014/05/01 09:20:12
Please add a class comment.
mtomasz
2014/05/02 01:26:22
Done.
| |
| 46 public: | |
| 47 FileSystemProviderInternalFunction(); | |
| 48 | |
| 49 protected: | |
| 50 virtual ~FileSystemProviderInternalFunction() {} | |
| 51 | |
| 52 // Rejects the request. If failed, then sets an error and returns false. The | |
| 53 // caller should also return false in such case. | |
|
hashimoto
2014/05/01 09:20:12
Since there are many parties (provider extension,
mtomasz
2014/05/02 01:26:22
I reworked the code to make it simpler. Now the me
| |
| 54 bool RejectRequest(base::File::Error error); | |
| 55 | |
| 56 // Fulfills the request. If failed, then sets an error and returns false. The | |
| 57 // caller should also return false then. | |
|
hashimoto
2014/05/01 09:20:12
ditto.
Also, please briefly describe what |value|
mtomasz
2014/05/02 01:26:22
Done.
| |
| 58 bool FulfillRequest( | |
| 59 scoped_ptr<chromeos::file_system_provider::RequestValue> value, | |
| 60 bool has_next); | |
| 61 | |
| 62 bool is_valid() { return is_valid_; } | |
|
hashimoto
2014/05/01 09:20:12
Please add a comment about what "valid" means.
mtomasz
2014/05/02 01:26:22
Removed.
| |
| 63 | |
| 64 // ChromeSyncExtensionFunction overrides. | |
| 65 virtual bool RunImpl() OVERRIDE; | |
| 66 | |
| 67 private: | |
| 68 // Parses the function args in order to acquire the file system id and the | |
| 69 // request id. Also, checks if the arguments are correct, and if there is a | |
| 70 // valid corresponding provided file system. On error, returns false. | |
| 71 bool Parse(); | |
| 72 | |
| 73 // Sets an error message in case of a failure. | |
| 74 void SetErrorMessage(const std::string& name, const std::string& message); | |
| 75 | |
| 76 int file_system_id_; | |
| 77 int request_id_; | |
| 78 bool is_valid_; | |
| 79 }; | |
| 80 | |
| 81 } // namespace extensions | |
| 82 | |
| 83 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_SYSTEM_PROVIDER_PROVIDER_FUNC TION_H_ | |
| OLD | NEW |