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

Side by Side Diff: content/renderer/mojo/interface_provider_js_wrapper.cc

Issue 2420253002: Rename shell namespace to service_manager (Closed)
Patch Set: . Created 4 years, 2 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/mojo/interface_provider_js_wrapper.h" 5 #include "content/renderer/mojo/interface_provider_js_wrapper.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "mojo/edk/js/handle.h" 10 #include "mojo/edk/js/handle.h"
11 #include "services/service_manager/public/cpp/interface_provider.h" 11 #include "services/service_manager/public/cpp/interface_provider.h"
12 #include "third_party/WebKit/public/web/WebLocalFrame.h" 12 #include "third_party/WebKit/public/web/WebLocalFrame.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 gin::WrapperInfo InterfaceProviderJsWrapper::kWrapperInfo = { 16 gin::WrapperInfo InterfaceProviderJsWrapper::kWrapperInfo = {
17 gin::kEmbedderNativeGin}; 17 gin::kEmbedderNativeGin};
18 const char InterfaceProviderJsWrapper::kPerFrameModuleName[] = 18 const char InterfaceProviderJsWrapper::kPerFrameModuleName[] =
19 "content/public/renderer/frame_interfaces"; 19 "content/public/renderer/frame_interfaces";
20 const char InterfaceProviderJsWrapper::kPerProcessModuleName[] = 20 const char InterfaceProviderJsWrapper::kPerProcessModuleName[] =
21 "content/public/renderer/interfaces"; 21 "content/public/renderer/interfaces";
22 22
23 InterfaceProviderJsWrapper::~InterfaceProviderJsWrapper() { 23 InterfaceProviderJsWrapper::~InterfaceProviderJsWrapper() {
24 } 24 }
25 25
26 // static 26 // static
27 gin::Handle<InterfaceProviderJsWrapper> 27 gin::Handle<InterfaceProviderJsWrapper> InterfaceProviderJsWrapper::Create(
28 InterfaceProviderJsWrapper::Create(
29 v8::Isolate* isolate, 28 v8::Isolate* isolate,
30 v8::Handle<v8::Context> context, 29 v8::Handle<v8::Context> context,
31 shell::InterfaceProvider* remote_interfaces) { 30 service_manager::InterfaceProvider* remote_interfaces) {
32 return gin::CreateHandle( 31 return gin::CreateHandle(
33 isolate, 32 isolate,
34 new InterfaceProviderJsWrapper( 33 new InterfaceProviderJsWrapper(
35 isolate, context, 34 isolate, context,
36 remote_interfaces->GetWeakPtr())); 35 remote_interfaces->GetWeakPtr()));
37 } 36 }
38 37
39 gin::ObjectTemplateBuilder 38 gin::ObjectTemplateBuilder
40 InterfaceProviderJsWrapper::GetObjectTemplateBuilder(v8::Isolate* isolate) { 39 InterfaceProviderJsWrapper::GetObjectTemplateBuilder(v8::Isolate* isolate) {
41 return Wrappable<InterfaceProviderJsWrapper>::GetObjectTemplateBuilder( 40 return Wrappable<InterfaceProviderJsWrapper>::GetObjectTemplateBuilder(
(...skipping 13 matching lines...) Expand all
55 remote_interfaces_->GetInterface( 54 remote_interfaces_->GetInterface(
56 interface_name, std::move(pipe.handle0)); 55 interface_name, std::move(pipe.handle0));
57 } 56 }
58 return pipe.handle1.release(); 57 return pipe.handle1.release();
59 } 58 }
60 59
61 void InterfaceProviderJsWrapper::AddOverrideForTesting( 60 void InterfaceProviderJsWrapper::AddOverrideForTesting(
62 const std::string& interface_name, 61 const std::string& interface_name,
63 v8::Local<v8::Function> service_factory) { 62 v8::Local<v8::Function> service_factory) {
64 ScopedJsFactory factory(v8::Isolate::GetCurrent(), service_factory); 63 ScopedJsFactory factory(v8::Isolate::GetCurrent(), service_factory);
65 shell::InterfaceProvider::TestApi test_api(remote_interfaces_.get()); 64 service_manager::InterfaceProvider::TestApi test_api(
65 remote_interfaces_.get());
66 test_api.SetBinderForName( 66 test_api.SetBinderForName(
67 interface_name, 67 interface_name,
68 base::Bind(&InterfaceProviderJsWrapper::CallJsFactory, 68 base::Bind(&InterfaceProviderJsWrapper::CallJsFactory,
69 weak_factory_.GetWeakPtr(), factory)); 69 weak_factory_.GetWeakPtr(), factory));
70 } 70 }
71 71
72 void InterfaceProviderJsWrapper::ClearOverridesForTesting() { 72 void InterfaceProviderJsWrapper::ClearOverridesForTesting() {
73 shell::InterfaceProvider::TestApi test_api(remote_interfaces_.get()); 73 service_manager::InterfaceProvider::TestApi test_api(
74 remote_interfaces_.get());
74 test_api.ClearBinders(); 75 test_api.ClearBinders();
75 } 76 }
76 77
77 InterfaceProviderJsWrapper::InterfaceProviderJsWrapper( 78 InterfaceProviderJsWrapper::InterfaceProviderJsWrapper(
78 v8::Isolate* isolate, 79 v8::Isolate* isolate,
79 v8::Handle<v8::Context> context, 80 v8::Handle<v8::Context> context,
80 base::WeakPtr<shell::InterfaceProvider> remote_interfaces) 81 base::WeakPtr<service_manager::InterfaceProvider> remote_interfaces)
81 : isolate_(isolate), 82 : isolate_(isolate),
82 context_(isolate, context), 83 context_(isolate, context),
83 remote_interfaces_(remote_interfaces), 84 remote_interfaces_(remote_interfaces),
84 weak_factory_(this) { 85 weak_factory_(this) {
85 context_.SetWeak(this, &InterfaceProviderJsWrapper::ClearContext, 86 context_.SetWeak(this, &InterfaceProviderJsWrapper::ClearContext,
86 v8::WeakCallbackType::kParameter); 87 v8::WeakCallbackType::kParameter);
87 } 88 }
88 89
89 void InterfaceProviderJsWrapper::CallJsFactory( 90 void InterfaceProviderJsWrapper::CallJsFactory(
90 const ScopedJsFactory& factory, 91 const ScopedJsFactory& factory,
(...skipping 12 matching lines...) Expand all
103 } 104 }
104 105
105 // static 106 // static
106 void InterfaceProviderJsWrapper::ClearContext( 107 void InterfaceProviderJsWrapper::ClearContext(
107 const v8::WeakCallbackInfo<InterfaceProviderJsWrapper>& data) { 108 const v8::WeakCallbackInfo<InterfaceProviderJsWrapper>& data) {
108 InterfaceProviderJsWrapper* registry = data.GetParameter(); 109 InterfaceProviderJsWrapper* registry = data.GetParameter();
109 registry->context_.Reset(); 110 registry->context_.Reset();
110 } 111 }
111 112
112 } // namespace content 113 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698