| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
| 12 #include "v8/include/v8.h" | 12 #include "v8/include/v8.h" |
| 13 | 13 |
| 14 namespace gin { | 14 namespace gin { |
| 15 class Arguments; | 15 class Arguments; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 class APIEventHandler; |
| 19 class APIRequestHandler; | 20 class APIRequestHandler; |
| 20 class APITypeReferenceMap; | 21 class APITypeReferenceMap; |
| 21 | 22 |
| 22 // Implementation of the storage.StorageArea custom type used in the | 23 // Implementation of the storage.StorageArea custom type used in the |
| 23 // chrome.storage API. | 24 // chrome.storage API. |
| 24 class StorageArea { | 25 class StorageArea { |
| 25 public: | 26 public: |
| 26 StorageArea(APIRequestHandler* request_handler, | 27 StorageArea(APIRequestHandler* request_handler, |
| 27 const APITypeReferenceMap* type_refs, | 28 const APITypeReferenceMap* type_refs, |
| 28 const std::string& name); | 29 const std::string& name); |
| 29 ~StorageArea(); | 30 ~StorageArea(); |
| 30 | 31 |
| 31 // Creates a StorageArea object for the given context and property name. | 32 // Creates a StorageArea object for the given context and property name. |
| 32 static v8::Local<v8::Object> CreateStorageArea( | 33 static v8::Local<v8::Object> CreateStorageArea( |
| 33 v8::Local<v8::Context> context, | 34 v8::Local<v8::Context> context, |
| 34 const std::string& property_name, | 35 const std::string& property_name, |
| 35 APIRequestHandler* request_handler, | 36 APIRequestHandler* request_handler, |
| 37 APIEventHandler* event_handler, |
| 36 APITypeReferenceMap* type_refs); | 38 APITypeReferenceMap* type_refs); |
| 37 | 39 |
| 38 void HandleFunctionCall(const std::string& method_name, | 40 void HandleFunctionCall(const std::string& method_name, |
| 39 gin::Arguments* arguments); | 41 gin::Arguments* arguments); |
| 40 | 42 |
| 41 private: | 43 private: |
| 42 APIRequestHandler* request_handler_; | 44 APIRequestHandler* request_handler_; |
| 43 | 45 |
| 44 const APITypeReferenceMap* type_refs_; | 46 const APITypeReferenceMap* type_refs_; |
| 45 | 47 |
| 46 std::string name_; | 48 std::string name_; |
| 47 | 49 |
| 48 DISALLOW_COPY_AND_ASSIGN(StorageArea); | 50 DISALLOW_COPY_AND_ASSIGN(StorageArea); |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 } // namespace extensions | 53 } // namespace extensions |
| 52 | 54 |
| 53 #endif // EXTENSIONS_RENDERER_STORAGE_AREA_H_ | 55 #endif // EXTENSIONS_RENDERER_STORAGE_AREA_H_ |
| OLD | NEW |