| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef EXTENSIONS_RENDERER_STORAGE_AREA_H_ | 5 #ifndef EXTENSIONS_RENDERER_STORAGE_AREA_H_ |
| 6 #define EXTENSIONS_RENDERER_STORAGE_AREA_H_ | 6 #define EXTENSIONS_RENDERER_STORAGE_AREA_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 #include <string> | 8 #include <string> |
| 10 | 9 |
| 11 #include "base/macros.h" | 10 #include "base/macros.h" |
| 12 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
| 13 #include "v8/include/v8.h" | 12 #include "v8/include/v8.h" |
| 14 | 13 |
| 15 namespace gin { | 14 namespace gin { |
| 16 class Arguments; | 15 class Arguments; |
| 17 } | 16 } |
| 18 | 17 |
| 19 namespace extensions { | 18 namespace extensions { |
| 19 class APIEventHandler; |
| 20 class APIRequestHandler; | 20 class APIRequestHandler; |
| 21 class APISignature; | |
| 22 class APITypeReferenceMap; | 21 class APITypeReferenceMap; |
| 23 | 22 |
| 24 // Implementation of the storage.StorageArea custom type used in the | 23 // Implementation of the storage.StorageArea custom type used in the |
| 25 // chrome.storage API. | 24 // chrome.storage API. |
| 26 class StorageArea { | 25 class StorageArea { |
| 27 public: | 26 public: |
| 28 StorageArea(APIRequestHandler* request_handler, | 27 StorageArea(APIRequestHandler* request_handler, |
| 29 const APITypeReferenceMap* type_refs, | 28 const APITypeReferenceMap* type_refs, |
| 30 const std::string& name); | 29 const std::string& name); |
| 31 ~StorageArea(); | 30 ~StorageArea(); |
| 32 | 31 |
| 33 // Creates a StorageArea object for the given context and property name. | 32 // Creates a StorageArea object for the given context and property name. |
| 34 static v8::Local<v8::Object> CreateStorageArea( | 33 static v8::Local<v8::Object> CreateStorageArea( |
| 35 v8::Local<v8::Context> context, | 34 v8::Local<v8::Context> context, |
| 36 const std::string& property_name, | 35 const std::string& property_name, |
| 37 APIRequestHandler* request_handler, | 36 APIRequestHandler* request_handler, |
| 37 APIEventHandler* event_handler, |
| 38 APITypeReferenceMap* type_refs); | 38 APITypeReferenceMap* type_refs); |
| 39 | 39 |
| 40 void HandleFunctionCall(const std::string& method_name, | 40 void HandleFunctionCall(const std::string& method_name, |
| 41 gin::Arguments* arguments); | 41 gin::Arguments* arguments); |
| 42 | 42 |
| 43 private: | 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_; | 44 APIRequestHandler* request_handler_; |
| 52 | 45 |
| 53 const APITypeReferenceMap* type_refs_; | 46 const APITypeReferenceMap* type_refs_; |
| 54 | 47 |
| 55 std::string name_; | 48 std::string name_; |
| 56 | 49 |
| 57 // TODO(devlin): See GetFunctionSchema. | |
| 58 std::map<std::string, std::unique_ptr<APISignature>> signatures_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(StorageArea); | 50 DISALLOW_COPY_AND_ASSIGN(StorageArea); |
| 61 }; | 51 }; |
| 62 | 52 |
| 63 } // namespace extensions | 53 } // namespace extensions |
| 64 | 54 |
| 65 #endif // EXTENSIONS_RENDERER_STORAGE_AREA_H_ | 55 #endif // EXTENSIONS_RENDERER_STORAGE_AREA_H_ |
| OLD | NEW |