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

Side by Side Diff: sky/shell/ui/engine.cc

Issue 962383003: Make shake-to-reload actually work (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « sky/shell/ui/engine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "sky/shell/ui/engine.h" 5 #include "sky/shell/ui/engine.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "mojo/public/cpp/application/connect.h" 8 #include "mojo/public/cpp/application/connect.h"
9 #include "sky/engine/public/platform/WebInputEvent.h" 9 #include "sky/engine/public/platform/WebInputEvent.h"
10 #include "sky/engine/public/web/Sky.h" 10 #include "sky/engine/public/web/Sky.h"
11 #include "sky/engine/public/web/WebLocalFrame.h" 11 #include "sky/engine/public/web/WebLocalFrame.h"
12 #include "sky/engine/public/web/WebSettings.h" 12 #include "sky/engine/public/web/WebSettings.h"
13 #include "sky/engine/public/web/WebView.h" 13 #include "sky/engine/public/web/WebView.h"
14 #include "sky/services/platform/platform_impl.h" 14 #include "sky/services/platform/platform_impl.h"
15 #include "sky/shell/java_service_provider.h"
15 #include "sky/shell/ui/animator.h" 16 #include "sky/shell/ui/animator.h"
16 #include "sky/shell/ui/input_event_converter.h" 17 #include "sky/shell/ui/input_event_converter.h"
17 #include "sky/shell/ui/internals.h" 18 #include "sky/shell/ui/internals.h"
18 #include "third_party/skia/include/core/SkCanvas.h" 19 #include "third_party/skia/include/core/SkCanvas.h"
19 #include "third_party/skia/include/core/SkPictureRecorder.h" 20 #include "third_party/skia/include/core/SkPictureRecorder.h"
20 21
21 namespace sky { 22 namespace sky {
22 namespace shell { 23 namespace shell {
23 24
24 namespace { 25 namespace {
25 26
26 void ConfigureSettings(blink::WebSettings* settings) { 27 void ConfigureSettings(blink::WebSettings* settings) {
27 settings->setDefaultFixedFontSize(13); 28 settings->setDefaultFixedFontSize(13);
28 settings->setDefaultFontSize(16); 29 settings->setDefaultFontSize(16);
29 settings->setLoadsImagesAutomatically(true); 30 settings->setLoadsImagesAutomatically(true);
30 } 31 }
31 32
32 } 33 }
33 34
34 Engine::Engine(const Config& config) 35 Engine::Engine(const Config& config)
35 : animator_(new Animator(config, this)), 36 : java_task_runner_(config.java_task_runner),
37 animator_(new Animator(config, this)),
36 web_view_(nullptr), 38 web_view_(nullptr),
37 device_pixel_ratio_(1.0f), 39 device_pixel_ratio_(1.0f),
38 viewport_observer_binding_(this), 40 viewport_observer_binding_(this),
39 weak_factory_(this) { 41 weak_factory_(this) {
40 } 42 }
41 43
42 Engine::~Engine() { 44 Engine::~Engine() {
43 if (web_view_) 45 if (web_view_)
44 web_view_->close(); 46 web_view_->close();
45 } 47 }
46 48
47 base::WeakPtr<Engine> Engine::GetWeakPtr() { 49 base::WeakPtr<Engine> Engine::GetWeakPtr() {
48 return weak_factory_.GetWeakPtr(); 50 return weak_factory_.GetWeakPtr();
49 } 51 }
50 52
51 void Engine::Init(mojo::ScopedMessagePipeHandle service_provider_handle) { 53 mojo::ServiceProviderPtr Engine::CreateServiceProvider() {
52 service_provider_ = 54 mojo::MessagePipe pipe;
53 mojo::MakeProxy<mojo::ServiceProvider>(service_provider_handle.Pass()); 55 java_task_runner_->PostTask(FROM_HERE, base::Bind(
56 CreateJavaServiceProvider,
57 base::Passed(mojo::MakeRequest<mojo::ServiceProvider>(
58 pipe.handle1.Pass()))));
59 return mojo::MakeProxy<mojo::ServiceProvider>(pipe.handle0.Pass());
60 }
61
62 void Engine::Init() {
63 service_provider_ = CreateServiceProvider();
54 mojo::NetworkServicePtr network_service; 64 mojo::NetworkServicePtr network_service;
55 mojo::ConnectToService(service_provider_.get(), &network_service); 65 mojo::ConnectToService(service_provider_.get(), &network_service);
56 platform_impl_.reset(new PlatformImpl(network_service.Pass())); 66 platform_impl_.reset(new PlatformImpl(network_service.Pass()));
57 67
58 blink::initialize(platform_impl_.get()); 68 blink::initialize(platform_impl_.get());
59 } 69 }
60 70
61 void Engine::BeginFrame(base::TimeTicks frame_time) { 71 void Engine::BeginFrame(base::TimeTicks frame_time) {
62 double frame_time_sec = (frame_time - base::TimeTicks()).InSecondsF(); 72 double frame_time_sec = (frame_time - base::TimeTicks()).InSecondsF();
63 double deadline_sec = frame_time_sec; 73 double deadline_sec = frame_time_sec;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 147
138 void Engine::initializeLayerTreeView() { 148 void Engine::initializeLayerTreeView() {
139 } 149 }
140 150
141 void Engine::scheduleVisualUpdate() { 151 void Engine::scheduleVisualUpdate() {
142 animator_->RequestFrame(); 152 animator_->RequestFrame();
143 } 153 }
144 154
145 void Engine::didCreateIsolate(blink::WebLocalFrame* frame, 155 void Engine::didCreateIsolate(blink::WebLocalFrame* frame,
146 Dart_Isolate isolate) { 156 Dart_Isolate isolate) {
147 Internals::Create(isolate, service_provider_.Pass()); 157 Internals::Create(isolate, CreateServiceProvider());
148 } 158 }
149 159
150 blink::ServiceProvider* Engine::services() { 160 blink::ServiceProvider* Engine::services() {
151 return this; 161 return this;
152 } 162 }
153 163
154 mojo::NavigatorHost* Engine::NavigatorHost() { 164 mojo::NavigatorHost* Engine::NavigatorHost() {
155 return this; 165 return this;
156 } 166 }
157 167
158 void Engine::RequestNavigate(mojo::Target target, 168 void Engine::RequestNavigate(mojo::Target target,
159 mojo::URLRequestPtr request) { 169 mojo::URLRequestPtr request) {
160 // Ignoring target for now. 170 // Ignoring target for now.
161 base::MessageLoop::current()->PostTask(FROM_HERE, 171 base::MessageLoop::current()->PostTask(FROM_HERE,
162 base::Bind(&Engine::LoadURL, GetWeakPtr(), request->url)); 172 base::Bind(&Engine::LoadURL, GetWeakPtr(), request->url));
163 } 173 }
164 174
165 void Engine::DidNavigateLocally(const mojo::String& url) { 175 void Engine::DidNavigateLocally(const mojo::String& url) {
166 } 176 }
167 177
168 void Engine::RequestNavigateHistory(int32_t delta) { 178 void Engine::RequestNavigateHistory(int32_t delta) {
169 NOTIMPLEMENTED(); 179 NOTIMPLEMENTED();
170 } 180 }
171 181
172 } // namespace shell 182 } // namespace shell
173 } // namespace sky 183 } // namespace sky
OLDNEW
« no previous file with comments | « sky/shell/ui/engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698