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

Side by Side Diff: mojo/shell/ui_service_loader_android.cc

Issue 423963004: First cut at "content handling" support in Mojo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more gn 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
« no previous file with comments | « mojo/shell/ui_service_loader_android.h ('k') | mojo/shell/view_manager_loader.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 "mojo/shell/ui_service_loader_android.h" 5 #include "mojo/shell/ui_service_loader_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "mojo/service_manager/service_manager.h" 8 #include "mojo/service_manager/service_manager.h"
9 #include "mojo/shell/context.h" 9 #include "mojo/shell/context.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 12
13 class UIServiceLoader::UILoader { 13 class UIServiceLoader::UILoader {
14 public: 14 public:
15 explicit UILoader(ServiceLoader* loader) : loader_(loader) {} 15 explicit UILoader(ServiceLoader* loader) : loader_(loader) {}
16 ~UILoader() {} 16 ~UILoader() {}
17 17
18 void LoadService(ServiceManager* manager, 18 void Load(ServiceManager* manager,
19 const GURL& url, 19 const GURL& url,
20 ScopedMessagePipeHandle shell_handle) { 20 ScopedMessagePipeHandle shell_handle) {
21 loader_->LoadService(manager, url, shell_handle.Pass()); 21 scoped_refptr<LoadCallbacks> callbacks(
22 new ServiceLoader::SimpleLoadCallbacks(shell_handle.Pass()));
23 loader_->Load(manager, url, callbacks);
22 } 24 }
23 25
24 void OnServiceError(ServiceManager* manager, const GURL& url) { 26 void OnServiceError(ServiceManager* manager, const GURL& url) {
25 loader_->OnServiceError(manager, url); 27 loader_->OnServiceError(manager, url);
26 } 28 }
27 29
28 private: 30 private:
29 ServiceLoader* loader_; // Owned by UIServiceLoader 31 ServiceLoader* loader_; // Owned by UIServiceLoader
30 32
31 DISALLOW_COPY_AND_ASSIGN(UILoader); 33 DISALLOW_COPY_AND_ASSIGN(UILoader);
32 }; 34 };
33 35
34 UIServiceLoader::UIServiceLoader(scoped_ptr<ServiceLoader> real_loader, 36 UIServiceLoader::UIServiceLoader(scoped_ptr<ServiceLoader> real_loader,
35 shell::Context* context) 37 shell::Context* context)
36 : loader_(real_loader.Pass()), context_(context) { 38 : loader_(real_loader.Pass()), context_(context) {
37 } 39 }
38 40
39 UIServiceLoader::~UIServiceLoader() { 41 UIServiceLoader::~UIServiceLoader() {
40 context_->ui_loop()->PostTask( 42 context_->ui_loop()->PostTask(
41 FROM_HERE, 43 FROM_HERE,
42 base::Bind(&UIServiceLoader::ShutdownOnUIThread, base::Unretained(this))); 44 base::Bind(&UIServiceLoader::ShutdownOnUIThread, base::Unretained(this)));
43 } 45 }
44 46
45 void UIServiceLoader::LoadService(ServiceManager* manager, 47 void UIServiceLoader::Load(ServiceManager* manager,
46 const GURL& url, 48 const GURL& url,
47 ScopedMessagePipeHandle shell_handle) { 49 scoped_refptr<LoadCallbacks> callbacks) {
50 ScopedMessagePipeHandle shell_handle = callbacks->RegisterApplication();
51 if (!shell_handle.is_valid())
52 return;
48 context_->ui_loop()->PostTask( 53 context_->ui_loop()->PostTask(
49 FROM_HERE, 54 FROM_HERE,
50 base::Bind( 55 base::Bind(&UIServiceLoader::LoadOnUIThread,
51 &UIServiceLoader::LoadServiceOnUIThread, 56 base::Unretained(this),
52 base::Unretained(this), 57 manager,
53 manager, 58 url,
54 url, 59 base::Owned(
55 base::Owned(new ScopedMessagePipeHandle(shell_handle.Pass())))); 60 new ScopedMessagePipeHandle(shell_handle.Pass()))));
56 } 61 }
57 62
58 void UIServiceLoader::OnServiceError(ServiceManager* manager, const GURL& url) { 63 void UIServiceLoader::OnServiceError(ServiceManager* manager, const GURL& url) {
59 context_->ui_loop()->PostTask( 64 context_->ui_loop()->PostTask(
60 FROM_HERE, 65 FROM_HERE,
61 base::Bind(&UIServiceLoader::OnServiceErrorOnUIThread, 66 base::Bind(&UIServiceLoader::OnServiceErrorOnUIThread,
62 base::Unretained(this), 67 base::Unretained(this),
63 manager, 68 manager,
64 url)); 69 url));
65 } 70 }
66 71
67 void UIServiceLoader::LoadServiceOnUIThread( 72 void UIServiceLoader::LoadOnUIThread(ServiceManager* manager,
68 ServiceManager* manager, 73 const GURL& url,
69 const GURL& url, 74 ScopedMessagePipeHandle* shell_handle) {
70 ScopedMessagePipeHandle* shell_handle) {
71 if (!ui_loader_) 75 if (!ui_loader_)
72 ui_loader_ = new UILoader(loader_.get()); 76 ui_loader_ = new UILoader(loader_.get());
73 ui_loader_->LoadService(manager, url, shell_handle->Pass()); 77 ui_loader_->Load(manager, url, shell_handle->Pass());
74 } 78 }
75 79
76 void UIServiceLoader::OnServiceErrorOnUIThread(ServiceManager* manager, 80 void UIServiceLoader::OnServiceErrorOnUIThread(ServiceManager* manager,
77 const GURL& url) { 81 const GURL& url) {
78 if (!ui_loader_) 82 if (!ui_loader_)
79 ui_loader_ = new UILoader(loader_.get()); 83 ui_loader_ = new UILoader(loader_.get());
80 ui_loader_->OnServiceError(manager, url); 84 ui_loader_->OnServiceError(manager, url);
81 } 85 }
82 86
83 void UIServiceLoader::ShutdownOnUIThread() { 87 void UIServiceLoader::ShutdownOnUIThread() {
84 delete ui_loader_; 88 delete ui_loader_;
85 // Destroy |loader_| on the thread it's actually used on. 89 // Destroy |loader_| on the thread it's actually used on.
86 loader_.reset(); 90 loader_.reset();
87 } 91 }
88 92
89 } // namespace mojo 93 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/ui_service_loader_android.h ('k') | mojo/shell/view_manager_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698