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

Side by Side 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, 7 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
(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 "chrome/browser/extensions/chrome_extension_function.h"
12 #include "chrome/common/extensions/api/file_system_provider.h"
13
14 class DictionaryValue;
hashimoto 2014/05/02 05:56:18 This should be in the base namespace.
mtomasz 2014/05/02 06:29:16 Done.
15
16 namespace chromeos {
17 namespace file_system_provider {
18
19 class RequestManager;
20 class RequestValue;
21
22 } // file_system_provider
23 } // chromeos
24
25 namespace extensions {
26
27 // Error names from
28 // http://www.w3.org/TR/file-system-api/#errors-and-exceptions
29 extern const char kNotFoundErrorName[];
30 extern const char kSecurityErrorName[];
31
32 // Error messages.
33 extern const char kEmptyNameErrorMessage[];
34 extern const char kMountFailedErrorMessage[];
35 extern const char kUnmountFailedErrorMessage[];
36 extern const char kResponseFailedErrorMessage[];
37
38 // Creates a dictionary, which looks like a DOMError. The returned dictionary
39 // will be converted to a real DOMError object in
40 // file_system_provier_custom_bindings.js.
41 base::DictionaryValue* CreateError(const std::string& name,
42 const std::string& message);
43
44 // Converts ProviderError to base::File::Error. This could be redundant, if it
45 // was possible to create DOMError instances in Javascript easily.
46 base::File::Error ProviderErrorToFileError(
47 api::file_system_provider::ProviderError error);
48
49 // Base class for internal API functions handling request results, either
50 // a success or a failure.
51 class FileSystemProviderInternalFunction : public ChromeSyncExtensionFunction {
52 public:
53 FileSystemProviderInternalFunction();
54
55 protected:
56 virtual ~FileSystemProviderInternalFunction() {}
57
58 // Rejects the request and sets a response for this API function. Returns
59 // 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.
60 void RejectRequest(base::File::Error error);
61
62 // 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.
63 // as a RequestValue instance. If |has_next| is set to true, then the function
64 // 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.
65 // the caller (RunImpl).
66 void FulfillRequest(
67 scoped_ptr<chromeos::file_system_provider::RequestValue> value,
68 bool has_next);
69
70 // ChromeSyncExtensionFunction overrides.
71 virtual bool RunImpl() OVERRIDE;
72
73 private:
74 // Parses the request in order to extract the request manager. If fails, then
75 // sets a response and returns false.
76 bool Parse();
77
78 // Sets an error message in case of a failure.
79 void SetErrorResponse(const std::string& name, const std::string& message);
80
81 int request_id_;
82 chromeos::file_system_provider::RequestManager* request_manager_;
83 };
84
85 } // namespace extensions
86
87 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_SYSTEM_PROVIDER_PROVIDER_FUNC TION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698