| 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 #include "extensions/renderer/storage_area.h" | 5 #include "extensions/renderer/storage_area.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "extensions/common/api/storage.h" | 9 #include "extensions/common/api/storage.h" |
| 10 #include "extensions/renderer/api_request_handler.h" | 10 #include "extensions/renderer/api_request_handler.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 const APITypeReferenceMap* type_refs, | 146 const APITypeReferenceMap* type_refs, |
| 147 const std::string& name) | 147 const std::string& name) |
| 148 : request_handler_(request_handler), type_refs_(type_refs), name_(name) {} | 148 : request_handler_(request_handler), type_refs_(type_refs), name_(name) {} |
| 149 StorageArea::~StorageArea() = default; | 149 StorageArea::~StorageArea() = default; |
| 150 | 150 |
| 151 // static | 151 // static |
| 152 v8::Local<v8::Object> StorageArea::CreateStorageArea( | 152 v8::Local<v8::Object> StorageArea::CreateStorageArea( |
| 153 v8::Local<v8::Context> context, | 153 v8::Local<v8::Context> context, |
| 154 const std::string& property_name, | 154 const std::string& property_name, |
| 155 APIRequestHandler* request_handler, | 155 APIRequestHandler* request_handler, |
| 156 APIEventHandler* event_handler, |
| 156 APITypeReferenceMap* type_refs) { | 157 APITypeReferenceMap* type_refs) { |
| 157 v8::Context::Scope context_scope(context); | 158 v8::Context::Scope context_scope(context); |
| 158 v8::Local<v8::Object> object; | 159 v8::Local<v8::Object> object; |
| 159 if (property_name == "local") { | 160 if (property_name == "local") { |
| 160 gin::Handle<LocalStorageArea> handle = | 161 gin::Handle<LocalStorageArea> handle = |
| 161 gin::CreateHandle(context->GetIsolate(), | 162 gin::CreateHandle(context->GetIsolate(), |
| 162 new LocalStorageArea(request_handler, type_refs)); | 163 new LocalStorageArea(request_handler, type_refs)); |
| 163 object = handle.ToV8().As<v8::Object>(); | 164 object = handle.ToV8().As<v8::Object>(); |
| 164 } else if (property_name == "sync") { | 165 } else if (property_name == "sync") { |
| 165 gin::Handle<SyncStorageArea> handle = gin::CreateHandle( | 166 gin::Handle<SyncStorageArea> handle = gin::CreateHandle( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 return; | 203 return; |
| 203 } | 204 } |
| 204 | 205 |
| 205 converted_arguments->Insert(0u, base::MakeUnique<base::Value>(name_)); | 206 converted_arguments->Insert(0u, base::MakeUnique<base::Value>(name_)); |
| 206 request_handler_->StartRequest(context, "storage." + method_name, | 207 request_handler_->StartRequest(context, "storage." + method_name, |
| 207 std::move(converted_arguments), callback, | 208 std::move(converted_arguments), callback, |
| 208 v8::Local<v8::Function>()); | 209 v8::Local<v8::Function>()); |
| 209 } | 210 } |
| 210 | 211 |
| 211 } // namespace extensions | 212 } // namespace extensions |
| OLD | NEW |