OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "mojo/apps/js/js_app.h" | |
6 #include "mojo/apps/js/js_content_handler_app.h" | |
7 | |
8 namespace mojo { | |
9 namespace apps { | |
10 | |
11 JSContentHandlerApp::JSContentHandlerApp() | |
12 : applicationImpl_(NULL), content_handler_factory_(this) { | |
13 } | |
14 | |
15 void JSContentHandlerApp::Initialize(ApplicationImpl* app) { | |
16 applicationImpl_ = app; | |
17 } | |
18 | |
19 JSContentHandlerApp::~JSContentHandlerApp() { | |
20 } | |
21 | |
22 bool JSContentHandlerApp::ConfigureIncomingConnection( | |
23 ApplicationConnection* connection) { | |
24 connection->AddService(&content_handler_factory_); | |
25 return true; | |
26 } | |
27 | |
28 void JSContentHandlerApp::StartJSApp( | |
29 const std::string& url, URLResponsePtr content) { | |
30 JSApp* app = new JSApp(this, url, content.Pass()); | |
31 apps_.push_back(app); | |
Aaron Boodman
2014/09/10 02:22:09
There does not seem to be any instance of JSConten
hansmuller
2014/09/11 00:26:17
At the moment the apps_ list entries defined the l
| |
32 // TODO(hansmuller): deal with the Start() return value. | |
33 app->Start(); | |
34 } | |
35 | |
36 void JSContentHandlerApp::QuitJSApp(JSApp* app) { | |
37 Apps::iterator itr = std::find(apps_.begin(), apps_.end(), app); | |
38 if (itr != apps_.end()) | |
39 apps_.erase(itr); | |
40 } | |
41 | |
42 void JSContentHandlerApp::ConnectToService(ScopedMessagePipeHandle pipe_handle1, | |
Aaron Boodman
2014/09/10 02:22:09
Since there is only one pipe handle here, you don'
hansmuller
2014/09/11 00:26:17
That was just a reminder that the caller was holdi
| |
43 const std::string& application_url, const std::string& interface_name) | |
44 { | |
45 CHECK(applicationImpl_); | |
46 ServiceProvider *service_provider = applicationImpl_->ConnectToApplication( | |
Aaron Boodman
2014/09/10 02:22:09
Instead of saving the ptr to ApplicationImpl*, sav
hansmuller
2014/09/11 00:26:17
ApplicationImpl::ConnectToApplication() updates an
Aaron Boodman
2014/09/11 05:24:53
Huh. I'm not really sure. I guess this can be part
| |
47 application_url)->GetServiceProvider(); | |
48 service_provider->ConnectToService(interface_name, pipe_handle1.Pass()); | |
49 } | |
50 | |
51 JSContentHandlerImpl::JSContentHandlerImpl(JSContentHandlerApp* app) | |
52 : content_handler_app_(app) { | |
53 } | |
54 | |
55 JSContentHandlerImpl::~JSContentHandlerImpl() { | |
56 } | |
57 | |
58 void JSContentHandlerImpl::OnConnect( | |
59 const mojo::String& url, | |
60 URLResponsePtr content, | |
61 InterfaceRequest<ServiceProvider> service_provider) { | |
62 content_handler_app_->StartJSApp(url.To<std::string>(), content.Pass()); | |
Aaron Boodman
2014/09/10 02:22:09
I'm not sure this is the right lifetime for these
Aaron Boodman
2014/09/11 05:24:53
We still need to figure this out. I suppose in can
| |
63 } | |
64 | |
65 } // namespace apps | |
66 } // namespace mojo | |
OLD | NEW |