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

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

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

Powered by Google App Engine
This is Rietveld 408576698