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

Side by Side Diff: shell/in_process_native_runner.cc

Issue 1088533003: Adding URLResponse Disk Cache to mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review Created 5 years, 7 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 | « shell/in_process_native_runner.h ('k') | shell/native_application_support.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "shell/in_process_native_runner.h" 5 #include "shell/in_process_native_runner.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/threading/platform_thread.h" 11 #include "base/threading/platform_thread.h"
12 #include "shell/native_application_support.h" 12 #include "shell/native_application_support.h"
13 13
14 namespace shell { 14 namespace shell {
15 15
16 InProcessNativeRunner::InProcessNativeRunner(Context* context) 16 InProcessNativeRunner::InProcessNativeRunner(Context* context)
17 : cleanup_(NativeApplicationCleanup::DONT_DELETE), app_library_(nullptr) { 17 : app_library_(nullptr) {
18 } 18 }
19 19
20 InProcessNativeRunner::~InProcessNativeRunner() { 20 InProcessNativeRunner::~InProcessNativeRunner() {
21 // It is important to let the thread exit before unloading the DSO (when 21 // It is important to let the thread exit before unloading the DSO (when
22 // app_library_ is destructed), because the library may have registered 22 // app_library_ is destructed), because the library may have registered
23 // thread-local data and destructors to run on thread termination. 23 // thread-local data and destructors to run on thread termination.
24 if (thread_) { 24 if (thread_) {
25 DCHECK(thread_->HasBeenStarted()); 25 DCHECK(thread_->HasBeenStarted());
26 DCHECK(!thread_->HasBeenJoined()); 26 DCHECK(!thread_->HasBeenJoined());
27 thread_->Join(); 27 thread_->Join();
28 } 28 }
29 } 29 }
30 30
31 void InProcessNativeRunner::Start( 31 void InProcessNativeRunner::Start(
32 const base::FilePath& app_path, 32 const base::FilePath& app_path,
33 NativeApplicationCleanup cleanup,
34 mojo::InterfaceRequest<mojo::Application> application_request, 33 mojo::InterfaceRequest<mojo::Application> application_request,
35 const base::Closure& app_completed_callback) { 34 const base::Closure& app_completed_callback) {
36 app_path_ = app_path; 35 app_path_ = app_path;
37 cleanup_ = cleanup;
38 36
39 DCHECK(!application_request_.is_pending()); 37 DCHECK(!application_request_.is_pending());
40 application_request_ = application_request.Pass(); 38 application_request_ = application_request.Pass();
41 39
42 DCHECK(app_completed_callback_runner_.is_null()); 40 DCHECK(app_completed_callback_runner_.is_null());
43 app_completed_callback_runner_ = 41 app_completed_callback_runner_ =
44 base::Bind(&base::TaskRunner::PostTask, base::MessageLoopProxy::current(), 42 base::Bind(&base::TaskRunner::PostTask, base::MessageLoopProxy::current(),
45 FROM_HERE, app_completed_callback); 43 FROM_HERE, app_completed_callback);
46 44
47 DCHECK(!thread_); 45 DCHECK(!thread_);
48 std::string thread_name = "app_thread_" + app_path_.BaseName().AsUTF8Unsafe(); 46 std::string thread_name = "app_thread_" + app_path_.BaseName().AsUTF8Unsafe();
49 thread_.reset(new base::DelegateSimpleThread(this, thread_name)); 47 thread_.reset(new base::DelegateSimpleThread(this, thread_name));
50 thread_->Start(); 48 thread_->Start();
51 } 49 }
52 50
53 void InProcessNativeRunner::Run() { 51 void InProcessNativeRunner::Run() {
54 DVLOG(2) << "Loading/running Mojo app in process from library: " 52 DVLOG(2) << "Loading/running Mojo app in process from library: "
55 << app_path_.value() 53 << app_path_.value()
56 << " thread id=" << base::PlatformThread::CurrentId(); 54 << " thread id=" << base::PlatformThread::CurrentId();
57 55
58 // TODO(vtl): ScopedNativeLibrary doesn't have a .get() method! 56 // TODO(vtl): ScopedNativeLibrary doesn't have a .get() method!
59 base::NativeLibrary app_library = LoadNativeApplication(app_path_, cleanup_); 57 base::NativeLibrary app_library = LoadNativeApplication(app_path_);
60 app_library_.Reset(app_library); 58 app_library_.Reset(app_library);
61 RunNativeApplication(app_library, application_request_.Pass()); 59 RunNativeApplication(app_library, application_request_.Pass());
62 app_completed_callback_runner_.Run(); 60 app_completed_callback_runner_.Run();
63 app_completed_callback_runner_.Reset(); 61 app_completed_callback_runner_.Reset();
64 } 62 }
65 63
66 scoped_ptr<NativeRunner> InProcessNativeRunnerFactory::Create( 64 scoped_ptr<NativeRunner> InProcessNativeRunnerFactory::Create(
67 const Options& options) { 65 const Options& options) {
68 return make_scoped_ptr(new InProcessNativeRunner(context_)); 66 return make_scoped_ptr(new InProcessNativeRunner(context_));
69 } 67 }
70 68
71 } // namespace shell 69 } // namespace shell
OLDNEW
« no previous file with comments | « shell/in_process_native_runner.h ('k') | shell/native_application_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698