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

Side by Side Diff: services/dart/dart_app.cc

Issue 868463008: Remove Client relationship between mojo.Shell/mojo.Application (Closed) Base URL: git@github.com:domokit/mojo.git@app_impl_init
Patch Set: fix android Created 5 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 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 "services/dart/dart_app.h" 5 #include "services/dart/dart_app.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "mojo/common/data_pipe_utils.h" 12 #include "mojo/common/data_pipe_utils.h"
13 #include "mojo/dart/embedder/dart_controller.h" 13 #include "mojo/dart/embedder/dart_controller.h"
14 #include "mojo/dart/embedder/isolate_data.h" 14 #include "mojo/dart/embedder/isolate_data.h"
15 #include "mojo/public/cpp/bindings/interface_request.h" 15 #include "mojo/public/cpp/bindings/interface_request.h"
16 16
17 using mojo::Application;
18
17 namespace dart { 19 namespace dart {
18 20
19 DartApp::DartApp(mojo::ShellPtr shell, mojo::URLResponsePtr response) 21 DartApp::DartApp(mojo::InterfaceRequest<Application> application_request,
20 : shell_(shell.Pass()) { 22 mojo::URLResponsePtr response)
23 : application_request_(application_request.Pass()) {
21 DCHECK(!response.is_null()); 24 DCHECK(!response.is_null());
22 std::string url(response->url); 25 std::string url(response->url);
23 std::string source; 26 std::string source;
24 CHECK(mojo::common::BlockingCopyToString(response->body.Pass(), &source)); 27 CHECK(mojo::common::BlockingCopyToString(response->body.Pass(), &source));
25 28
26 // TODO(zra): Where is the package root? For now, use DIR_EXE/gen. 29 // TODO(zra): Where is the package root? For now, use DIR_EXE/gen.
27 base::FilePath package_root; 30 base::FilePath package_root;
28 PathService::Get(base::DIR_EXE, &package_root); 31 PathService::Get(base::DIR_EXE, &package_root);
29 package_root = package_root.AppendASCII("gen"); 32 package_root = package_root.AppendASCII("gen");
30 33
31 config_.application_data = reinterpret_cast<void*>(this); 34 config_.application_data = reinterpret_cast<void*>(this);
32 config_.script = source; 35 config_.script = source;
33 config_.script_uri = url; 36 config_.script_uri = url;
34 config_.package_root = package_root.AsUTF8Unsafe(); 37 config_.package_root = package_root.AsUTF8Unsafe();
35 config_.entropy = nullptr; 38 config_.entropy = nullptr;
36 config_.arguments = nullptr; 39 config_.arguments = nullptr;
37 config_.arguments_count = 0; 40 config_.arguments_count = 0;
38 config_.compile_all = false; 41 config_.compile_all = false;
39 42
40 base::MessageLoop::current()->PostTask(FROM_HERE, 43 base::MessageLoop::current()->PostTask(FROM_HERE,
41 base::Bind(&DartApp::OnAppLoaded, base::Unretained(this))); 44 base::Bind(&DartApp::OnAppLoaded, base::Unretained(this)));
42 } 45 }
43 46
44 DartApp::~DartApp() { 47 DartApp::~DartApp() {
45 } 48 }
46 49
47 void DartApp::OnAppLoaded() { 50 void DartApp::OnAppLoaded() {
48 char* error = nullptr; 51 char* error = nullptr;
49 config_.handle = shell_.PassMessagePipe().release().value(); 52 config_.handle = application_request_.PassMessagePipe().release().value();
50 config_.error = &error; 53 config_.error = &error;
51 bool success = mojo::dart::DartController::RunDartScript(config_); 54 bool success = mojo::dart::DartController::RunDartScript(config_);
52 if (!success) { 55 if (!success) {
53 LOG(ERROR) << error; 56 LOG(ERROR) << error;
54 free(error); 57 free(error);
55 } 58 }
56 base::MessageLoop::current()->QuitWhenIdle(); 59 base::MessageLoop::current()->QuitWhenIdle();
57 } 60 }
58 61
59 } // namespace dart 62 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698