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

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

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

Powered by Google App Engine
This is Rietveld 408576698