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

Unified Diff: chrome/browser/chromeos/extensions/file_system_provider/provider_function.h

Issue 260943002: [fsp] Extract common code to FileSystemProvidedInternalFunction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplified + addressed comments. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/extensions/file_system_provider/provider_function.h
diff --git a/chrome/browser/chromeos/extensions/file_system_provider/provider_function.h b/chrome/browser/chromeos/extensions/file_system_provider/provider_function.h
new file mode 100644
index 0000000000000000000000000000000000000000..3210e7e3910e97e8ae1c986fe45e802578c1f1bc
--- /dev/null
+++ b/chrome/browser/chromeos/extensions/file_system_provider/provider_function.h
@@ -0,0 +1,87 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_SYSTEM_PROVIDER_PROVIDER_FUNCTION_H_
+#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_SYSTEM_PROVIDER_PROVIDER_FUNCTION_H_
+#include <string>
+
+#include "base/files/file.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/extensions/chrome_extension_function.h"
+#include "chrome/common/extensions/api/file_system_provider.h"
+
+class DictionaryValue;
hashimoto 2014/05/02 05:56:18 This should be in the base namespace.
mtomasz 2014/05/02 06:29:16 Done.
+
+namespace chromeos {
+namespace file_system_provider {
+
+class RequestManager;
+class RequestValue;
+
+} // file_system_provider
+} // chromeos
+
+namespace extensions {
+
+// Error names from
+// http://www.w3.org/TR/file-system-api/#errors-and-exceptions
+extern const char kNotFoundErrorName[];
+extern const char kSecurityErrorName[];
+
+// Error messages.
+extern const char kEmptyNameErrorMessage[];
+extern const char kMountFailedErrorMessage[];
+extern const char kUnmountFailedErrorMessage[];
+extern const char kResponseFailedErrorMessage[];
+
+// Creates a dictionary, which looks like a DOMError. The returned dictionary
+// will be converted to a real DOMError object in
+// file_system_provier_custom_bindings.js.
+base::DictionaryValue* CreateError(const std::string& name,
+ const std::string& message);
+
+// Converts ProviderError to base::File::Error. This could be redundant, if it
+// was possible to create DOMError instances in Javascript easily.
+base::File::Error ProviderErrorToFileError(
+ api::file_system_provider::ProviderError error);
+
+// Base class for internal API functions handling request results, either
+// a success or a failure.
+class FileSystemProviderInternalFunction : public ChromeSyncExtensionFunction {
+ public:
+ FileSystemProviderInternalFunction();
+
+ protected:
+ virtual ~FileSystemProviderInternalFunction() {}
+
+ // Rejects the request and sets a response for this API function. Returns
+ // a value to be returned by the caller (RunImpl).
hashimoto 2014/05/02 05:56:18 Seems this function returns nothing?
mtomasz 2014/05/02 06:29:16 Done.
+ void RejectRequest(base::File::Error error);
+
+ // Fulfils the request with parsed arguments of this API function encapsulated
hashimoto 2014/05/02 05:56:18 nit: s/Fulfils/Fulfills/
mtomasz 2014/05/02 06:29:16 Done.
+ // as a RequestValue instance. If |has_next| is set to true, then the function
+ // will be called again for this request. Returns a value to be returned by
hashimoto 2014/05/02 05:56:18 Seems this function returns nothing?
mtomasz 2014/05/02 06:29:16 Done.
+ // the caller (RunImpl).
+ void FulfillRequest(
+ scoped_ptr<chromeos::file_system_provider::RequestValue> value,
+ bool has_next);
+
+ // ChromeSyncExtensionFunction overrides.
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ // Parses the request in order to extract the request manager. If fails, then
+ // sets a response and returns false.
+ bool Parse();
+
+ // Sets an error message in case of a failure.
+ void SetErrorResponse(const std::string& name, const std::string& message);
+
+ int request_id_;
+ chromeos::file_system_provider::RequestManager* request_manager_;
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_SYSTEM_PROVIDER_PROVIDER_FUNCTION_H_

Powered by Google App Engine
This is Rietveld 408576698