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

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

Issue 1218323002: Hook up test runner to new layout_test_html_viewer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 5 years, 5 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "components/html_viewer/global_state.h" 9 #include "components/html_viewer/global_state.h"
10 #include "components/html_viewer/html_document.h"
11 #include "components/html_viewer/html_document_oopif.h" 10 #include "components/html_viewer/html_document_oopif.h"
12 #include "components/html_viewer/html_viewer_switches.h" 11 #include "components/html_viewer/html_viewer_switches.h"
13 #include "mojo/application/public/cpp/application_connection.h" 12 #include "mojo/application/public/cpp/application_connection.h"
14 #include "mojo/application/public/cpp/application_delegate.h" 13 #include "mojo/application/public/cpp/application_delegate.h"
15 #include "mojo/application/public/cpp/connect.h" 14 #include "mojo/application/public/cpp/connect.h"
16 15
17 namespace html_viewer { 16 namespace html_viewer {
18 17
19 namespace { 18 namespace {
20 19
21 bool EnableOOPIFs() { 20 bool EnableOOPIFs() {
22 return base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kOOPIF); 21 return base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kOOPIF);
23 } 22 }
24 23
24 HTMLDocument* CreateHTMLDocument(HTMLDocument::CreateParams* params) {
25 return new HTMLDocument(params);
26 }
27
25 } // namespace 28 } // namespace
26 29
27 // ServiceConnectorQueue records all incoming service requests and processes 30 // ServiceConnectorQueue records all incoming service requests and processes
28 // them once PushRequestsTo() is called. This is useful if you need to delay 31 // them once PushRequestsTo() is called. This is useful if you need to delay
29 // processing incoming service requests. 32 // processing incoming service requests.
30 class HTMLDocumentApplicationDelegate::ServiceConnectorQueue 33 class HTMLDocumentApplicationDelegate::ServiceConnectorQueue
31 : public mojo::ServiceConnector { 34 : public mojo::ServiceConnector {
32 public: 35 public:
33 ServiceConnectorQueue() {} 36 ServiceConnectorQueue() {}
34 ~ServiceConnectorQueue() override {} 37 ~ServiceConnectorQueue() override {}
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 mojo::URLResponsePtr response, 71 mojo::URLResponsePtr response,
69 GlobalState* global_state, 72 GlobalState* global_state,
70 scoped_ptr<mojo::AppRefCount> parent_app_refcount) 73 scoped_ptr<mojo::AppRefCount> parent_app_refcount)
71 : app_(this, 74 : app_(this,
72 request.Pass(), 75 request.Pass(),
73 base::Bind(&HTMLDocumentApplicationDelegate::OnTerminate, 76 base::Bind(&HTMLDocumentApplicationDelegate::OnTerminate,
74 base::Unretained(this))), 77 base::Unretained(this))),
75 parent_app_refcount_(parent_app_refcount.Pass()), 78 parent_app_refcount_(parent_app_refcount.Pass()),
76 url_(response->url), 79 url_(response->url),
77 initial_response_(response.Pass()), 80 initial_response_(response.Pass()),
78 global_state_(global_state) { 81 global_state_(global_state),
82 html_document_creation_callback_(base::Bind(CreateHTMLDocument)) {
79 } 83 }
80 84
81 HTMLDocumentApplicationDelegate::~HTMLDocumentApplicationDelegate() { 85 HTMLDocumentApplicationDelegate::~HTMLDocumentApplicationDelegate() {
82 // Deleting the documents is going to trigger a callback to 86 // Deleting the documents is going to trigger a callback to
83 // OnHTMLDocumentDeleted() and remove from |documents_|. Copy the set so we 87 // OnHTMLDocumentDeleted() and remove from |documents_|. Copy the set so we
84 // don't have to worry about the set being modified out from under us. 88 // don't have to worry about the set being modified out from under us.
85 std::set<HTMLDocument*> documents(documents_); 89 std::set<HTMLDocument*> documents(documents_);
86 for (HTMLDocument* doc : documents) 90 for (HTMLDocument* doc : documents)
87 doc->Destroy(); 91 doc->Destroy();
88 DCHECK(documents_.empty()); 92 DCHECK(documents_.empty());
89 93
90 std::set<HTMLDocumentOOPIF*> documents2(documents2_); 94 std::set<HTMLDocumentOOPIF*> documents2(documents2_);
91 for (HTMLDocumentOOPIF* doc : documents2) 95 for (HTMLDocumentOOPIF* doc : documents2)
92 doc->Destroy(); 96 doc->Destroy();
93 DCHECK(documents2_.empty()); 97 DCHECK(documents2_.empty());
94 } 98 }
95 99
100 void HTMLDocumentApplicationDelegate::SetHTMLDocumentCreationCallback(
101 const HTMLDocumentCreationCallback& callback) {
102 html_document_creation_callback_ = callback;
103 }
104
96 // Callback from the quit closure. We key off this rather than 105 // Callback from the quit closure. We key off this rather than
97 // ApplicationDelegate::Quit() as we don't want to shut down the messageloop 106 // ApplicationDelegate::Quit() as we don't want to shut down the messageloop
98 // when we quit (the messageloop is shared among multiple 107 // when we quit (the messageloop is shared among multiple
99 // HTMLDocumentApplicationDelegates). 108 // HTMLDocumentApplicationDelegates).
100 void HTMLDocumentApplicationDelegate::OnTerminate() { 109 void HTMLDocumentApplicationDelegate::OnTerminate() {
101 delete this; 110 delete this;
102 } 111 }
103 112
104 // ApplicationDelegate; 113 // ApplicationDelegate;
105 void HTMLDocumentApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { 114 void HTMLDocumentApplicationDelegate::Initialize(mojo::ApplicationImpl* app) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 HTMLDocumentOOPIF* document = new HTMLDocumentOOPIF( 174 HTMLDocumentOOPIF* document = new HTMLDocumentOOPIF(
166 &app_, connection, response.Pass(), global_state_, 175 &app_, connection, response.Pass(), global_state_,
167 base::Bind(&HTMLDocumentApplicationDelegate::OnHTMLDocumentDeleted2, 176 base::Bind(&HTMLDocumentApplicationDelegate::OnHTMLDocumentDeleted2,
168 base::Unretained(this))); 177 base::Unretained(this)));
169 documents2_.insert(document); 178 documents2_.insert(document);
170 } else { 179 } else {
171 HTMLDocument::CreateParams params( 180 HTMLDocument::CreateParams params(
172 &app_, connection, response.Pass(), global_state_, 181 &app_, connection, response.Pass(), global_state_,
173 base::Bind(&HTMLDocumentApplicationDelegate::OnHTMLDocumentDeleted, 182 base::Bind(&HTMLDocumentApplicationDelegate::OnHTMLDocumentDeleted,
174 base::Unretained(this))); 183 base::Unretained(this)));
175 HTMLDocument* document = new HTMLDocument(&params); 184 HTMLDocument* document = html_document_creation_callback_.Run(&params);
176 documents_.insert(document); 185 documents_.insert(document);
177 } 186 }
178 187
179 if (connector_queue) { 188 if (connector_queue) {
180 connector_queue->PushRequestsTo(connection); 189 connector_queue->PushRequestsTo(connection);
181 connection->SetServiceConnector(nullptr); 190 connection->SetServiceConnector(nullptr);
182 } 191 }
183 } 192 }
184 193
185 } // namespace html_viewer 194 } // namespace html_viewer
OLDNEW
« no previous file with comments | « components/html_viewer/html_document_application_delegate.h ('k') | components/html_viewer/html_viewer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698