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

Side by Side Diff: components/html_viewer/html_document_application_delegate.cc

Issue 1674903003: Extract shell methods from ApplicationImpl into a base class, and pass this to Initialize() instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojom
Patch Set: . Created 4 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/html_viewer/html_document_application_delegate.h" 5 #include "components/html_viewer/html_document_application_delegate.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 // Callback from the quit closure. We key off this rather than 87 // Callback from the quit closure. We key off this rather than
88 // ApplicationDelegate::Quit() as we don't want to shut down the messageloop 88 // ApplicationDelegate::Quit() as we don't want to shut down the messageloop
89 // when we quit (the messageloop is shared among multiple 89 // when we quit (the messageloop is shared among multiple
90 // HTMLDocumentApplicationDelegates). 90 // HTMLDocumentApplicationDelegates).
91 void HTMLDocumentApplicationDelegate::OnTerminate() { 91 void HTMLDocumentApplicationDelegate::OnTerminate() {
92 delete this; 92 delete this;
93 } 93 }
94 94
95 // ApplicationDelegate; 95 // ApplicationDelegate;
96 void HTMLDocumentApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { 96 void HTMLDocumentApplicationDelegate::Initialize(mojo::Shell* shell,
97 const std::string& url,
98 uint32_t id) {
97 app_.ConnectToService("mojo:network_service", &url_loader_factory_); 99 app_.ConnectToService("mojo:network_service", &url_loader_factory_);
98 } 100 }
99 101
100 bool HTMLDocumentApplicationDelegate::AcceptConnection( 102 bool HTMLDocumentApplicationDelegate::AcceptConnection(
101 mojo::ApplicationConnection* connection) { 103 mojo::ApplicationConnection* connection) {
102 if (initial_response_) { 104 if (initial_response_) {
103 OnResponseReceived(nullptr, mojo::URLLoaderPtr(), connection, nullptr, 105 OnResponseReceived(nullptr, mojo::URLLoaderPtr(), connection, nullptr,
104 std::move(initial_response_)); 106 std::move(initial_response_));
105 } else if (url_ == "about:blank") { 107 } else if (url_ == "about:blank") {
106 // This is a little unfortunate. At the browser side, when starting a new 108 // This is a little unfortunate. At the browser side, when starting a new
(...skipping 21 matching lines...) Expand all
128 mojo::URLRequestPtr request(mojo::URLRequest::New()); 130 mojo::URLRequestPtr request(mojo::URLRequest::New());
129 request->url = url_; 131 request->url = url_;
130 request->auto_follow_redirects = true; 132 request->auto_follow_redirects = true;
131 133
132 // |loader| will be passed to the OnResponseReceived method through a 134 // |loader| will be passed to the OnResponseReceived method through a
133 // callback. Because order of evaluation is undefined, a reference to the 135 // callback. Because order of evaluation is undefined, a reference to the
134 // raw pointer is needed. 136 // raw pointer is needed.
135 mojo::URLLoader* raw_loader = loader.get(); 137 mojo::URLLoader* raw_loader = loader.get();
136 // The app needs to stay alive while waiting for the response to be 138 // The app needs to stay alive while waiting for the response to be
137 // available. 139 // available.
138 scoped_ptr<mojo::AppRefCount> app_retainer( 140 scoped_ptr<mojo::AppRefCount> app_retainer(app_.CreateAppRefCount());
139 app_.app_lifetime_helper()->CreateAppRefCount());
140 raw_loader->Start( 141 raw_loader->Start(
141 std::move(request), 142 std::move(request),
142 base::Bind(&HTMLDocumentApplicationDelegate::OnResponseReceived, 143 base::Bind(&HTMLDocumentApplicationDelegate::OnResponseReceived,
143 weak_factory_.GetWeakPtr(), base::Passed(&app_retainer), 144 weak_factory_.GetWeakPtr(), base::Passed(&app_retainer),
144 base::Passed(&loader), connection, 145 base::Passed(&loader), connection,
145 base::Passed(&service_connector_queue))); 146 base::Passed(&service_connector_queue)));
146 } 147 }
147 return true; 148 return true;
148 } 149 }
149 150
(...skipping 28 matching lines...) Expand all
178 HTMLFrame::CreateParams* params) { 179 HTMLFrame::CreateParams* params) {
179 return new HTMLFrame(params); 180 return new HTMLFrame(params);
180 } 181 }
181 182
182 HTMLWidgetRootLocal* HTMLDocumentApplicationDelegate::CreateHTMLWidgetRootLocal( 183 HTMLWidgetRootLocal* HTMLDocumentApplicationDelegate::CreateHTMLWidgetRootLocal(
183 HTMLWidgetRootLocal::CreateParams* params) { 184 HTMLWidgetRootLocal::CreateParams* params) {
184 return new HTMLWidgetRootLocal(params); 185 return new HTMLWidgetRootLocal(params);
185 } 186 }
186 187
187 } // namespace html_viewer 188 } // namespace html_viewer
OLDNEW
« no previous file with comments | « components/html_viewer/html_document_application_delegate.h ('k') | components/html_viewer/html_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698