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

Side by Side Diff: mojo/service_manager/background_shell_service_loader.cc

Issue 394903005: mojo: terminate apps if the shell goes away (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable tests that touch nss for now Created 6 years, 4 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 | Annotate | Revision Log
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 "mojo/service_manager/background_shell_service_loader.h" 5 #include "mojo/service_manager/background_shell_service_loader.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "mojo/service_manager/service_manager.h" 9 #include "mojo/service_manager/service_manager.h"
10 10
(...skipping 17 matching lines...) Expand all
28 private: 28 private:
29 ServiceLoader* loader_; // Owned by BackgroundShellServiceLoader 29 ServiceLoader* loader_; // Owned by BackgroundShellServiceLoader
30 30
31 DISALLOW_COPY_AND_ASSIGN(BackgroundLoader); 31 DISALLOW_COPY_AND_ASSIGN(BackgroundLoader);
32 }; 32 };
33 33
34 BackgroundShellServiceLoader::BackgroundShellServiceLoader( 34 BackgroundShellServiceLoader::BackgroundShellServiceLoader(
35 scoped_ptr<ServiceLoader> real_loader, 35 scoped_ptr<ServiceLoader> real_loader,
36 const std::string& thread_name, 36 const std::string& thread_name,
37 base::MessageLoop::Type message_loop_type) 37 base::MessageLoop::Type message_loop_type)
38 : quit_on_shutdown_(false), 38 : loader_(real_loader.Pass()),
39 loader_(real_loader.Pass()),
40 message_loop_type_(message_loop_type), 39 message_loop_type_(message_loop_type),
41 thread_name_(thread_name), 40 thread_name_(thread_name),
42 message_loop_created_(true, false), 41 message_loop_created_(true, false),
43 background_loader_(NULL) { 42 background_loader_(NULL) {
44 } 43 }
45 44
46 BackgroundShellServiceLoader::~BackgroundShellServiceLoader() { 45 BackgroundShellServiceLoader::~BackgroundShellServiceLoader() {
47 if (thread_) { 46 if (thread_)
48 if (quit_on_shutdown_)
49 task_runner_->PostTask(FROM_HERE, quit_closure_);
50 thread_->Join(); 47 thread_->Join();
51 }
52 } 48 }
53 49
54 void BackgroundShellServiceLoader::LoadService( 50 void BackgroundShellServiceLoader::LoadService(
55 ServiceManager* manager, 51 ServiceManager* manager,
56 const GURL& url, 52 const GURL& url,
57 ScopedMessagePipeHandle shell_handle) { 53 ScopedMessagePipeHandle shell_handle) {
58 if (!thread_) { 54 if (!thread_) {
59 // TODO(tim): It'd be nice if we could just have each LoadService call 55 // TODO(tim): It'd be nice if we could just have each LoadService call
60 // result in a new thread like DynamicService{Loader, Runner}. But some 56 // result in a new thread like DynamicService{Loader, Runner}. But some
61 // loaders are creating multiple ApplicationImpls (NetworkServiceLoader) 57 // loaders are creating multiple ApplicationImpls (NetworkServiceLoader)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 105
110 void BackgroundShellServiceLoader::OnServiceErrorOnBackgroundThread( 106 void BackgroundShellServiceLoader::OnServiceErrorOnBackgroundThread(
111 ServiceManager* manager, const GURL& url) { 107 ServiceManager* manager, const GURL& url) {
112 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 108 DCHECK(task_runner_->RunsTasksOnCurrentThread());
113 if (!background_loader_) 109 if (!background_loader_)
114 background_loader_ = new BackgroundLoader(loader_.get()); 110 background_loader_ = new BackgroundLoader(loader_.get());
115 background_loader_->OnServiceError(manager, url); 111 background_loader_->OnServiceError(manager, url);
116 } 112 }
117 113
118 } // namespace mojo 114 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698