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

Side by Side Diff: extensions/renderer/storage_area.h

Issue 2704823002: [Extensions Bindings] Add support for custom property types (Closed)
Patch Set: . Created 3 years, 10 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
(Empty)
1 // Copyright 2017 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 EXTENSIONS_RENDERER_STORAGE_AREA_H_
6 #define EXTENSIONS_RENDERER_STORAGE_AREA_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/macros.h"
12 #include "base/strings/string_piece.h"
13 #include "v8/include/v8.h"
14
15 namespace gin {
16 class Arguments;
17 class ObjectTemplateBuilder;
18 }
19
20 namespace extensions {
21 class APIRequestHandler;
22 class APISignature;
23 class APITypeReferenceMap;
24
25 // Implementation of the storage.StorageArea custom type used in the
26 // chrome.storage API.
27 class StorageArea {
28 public:
29 StorageArea(APIRequestHandler* request_handler,
30 const APITypeReferenceMap* type_refs,
31 const std::string& name);
32 ~StorageArea();
33
34 // Creates a StorageArea object for the given context and property name.
35 static v8::Local<v8::Object> CreateStorageArea(
36 v8::Local<v8::Context> context,
37 const std::string& property_name,
38 APIRequestHandler* request_handler,
39 APITypeReferenceMap* type_refs);
40
41 void DecorateTemplate(gin::ObjectTemplateBuilder* builder);
42
43 private:
44 void HandleFunctionCall(const std::string& method_name,
45 gin::Arguments* arguments);
46
47 // Returns the schema associated with the specified function.
48 // TODO(devlin): Other custom types will need this, too; move it out of here
49 // when more exist.
50 const APISignature& GetFunctionSchema(base::StringPiece api_name,
51 base::StringPiece type_name,
52 base::StringPiece function_name);
53
54 APIRequestHandler* request_handler_;
55
56 const APITypeReferenceMap* type_refs_;
57
58 std::string name_;
59
60 // TODO(devlin): See GetFunctionSchema.
61 std::map<std::string, std::unique_ptr<APISignature>> signatures_;
62
63 DISALLOW_COPY_AND_ASSIGN(StorageArea);
64 };
65
66 } // namespace extensions
67
68 #endif // EXTENSIONS_RENDERER_STORAGE_AREA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698