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

Side by Side Diff: mojo/examples/html_viewer/html_viewer.cc

Issue 373373002: Mojo: Refactor URLLoader interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes per review Created 6 years, 5 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/examples/html_viewer/blink_platform_impl.h" 5 #include "mojo/examples/html_viewer/blink_platform_impl.h"
6 #include "mojo/examples/html_viewer/html_document_view.h" 6 #include "mojo/examples/html_viewer/html_document_view.h"
7 #include "mojo/public/cpp/application/application_connection.h" 7 #include "mojo/public/cpp/application/application_connection.h"
8 #include "mojo/public/cpp/application/application_delegate.h" 8 #include "mojo/public/cpp/application/application_delegate.h"
9 #include "mojo/public/cpp/application/application_impl.h" 9 #include "mojo/public/cpp/application/application_impl.h"
10 #include "mojo/services/public/cpp/view_manager/node.h" 10 #include "mojo/services/public/cpp/view_manager/node.h"
(...skipping 29 matching lines...) Expand all
40 40
41 class HTMLViewer : public ApplicationDelegate, 41 class HTMLViewer : public ApplicationDelegate,
42 public view_manager::ViewManagerDelegate { 42 public view_manager::ViewManagerDelegate {
43 public: 43 public:
44 HTMLViewer() : application_impl_(NULL), document_view_(NULL) { 44 HTMLViewer() : application_impl_(NULL), document_view_(NULL) {
45 } 45 }
46 virtual ~HTMLViewer() { 46 virtual ~HTMLViewer() {
47 blink::shutdown(); 47 blink::shutdown();
48 } 48 }
49 49
50 void Load(URLResponsePtr response, 50 void Load(URLResponsePtr response) {
51 ScopedDataPipeConsumerHandle response_body_stream) {
52 // Need to wait for OnRootAdded. 51 // Need to wait for OnRootAdded.
53 response_ = response.Pass(); 52 response_ = response.Pass();
54 response_body_stream_ = response_body_stream.Pass();
55 MaybeLoad(); 53 MaybeLoad();
56 } 54 }
57 55
58 private: 56 private:
59 // Overridden from ApplicationDelegate: 57 // Overridden from ApplicationDelegate:
60 virtual void Initialize(ApplicationImpl* app) OVERRIDE { 58 virtual void Initialize(ApplicationImpl* app) OVERRIDE {
61 application_impl_ = app; 59 application_impl_ = app;
62 blink_platform_impl_.reset(new BlinkPlatformImpl(app)); 60 blink_platform_impl_.reset(new BlinkPlatformImpl(app));
63 blink::initialize(blink_platform_impl_.get()); 61 blink::initialize(blink_platform_impl_.get());
64 } 62 }
(...skipping 10 matching lines...) Expand all
75 view_manager::Node* root) OVERRIDE { 73 view_manager::Node* root) OVERRIDE {
76 document_view_ = new HTMLDocumentView( 74 document_view_ = new HTMLDocumentView(
77 application_impl_->ConnectToApplication("mojo://mojo_window_manager/")-> 75 application_impl_->ConnectToApplication("mojo://mojo_window_manager/")->
78 GetServiceProvider(), view_manager); 76 GetServiceProvider(), view_manager);
79 document_view_->AttachToNode(root); 77 document_view_->AttachToNode(root);
80 MaybeLoad(); 78 MaybeLoad();
81 } 79 }
82 80
83 void MaybeLoad() { 81 void MaybeLoad() {
84 if (document_view_ && response_.get()) 82 if (document_view_ && response_.get())
85 document_view_->Load(response_.Pass(), response_body_stream_.Pass()); 83 document_view_->Load(response_.Pass());
86 } 84 }
87 85
88 scoped_ptr<BlinkPlatformImpl> blink_platform_impl_; 86 scoped_ptr<BlinkPlatformImpl> blink_platform_impl_;
89 ApplicationImpl* application_impl_; 87 ApplicationImpl* application_impl_;
90 88
91 // TODO(darin): Figure out proper ownership of this instance. 89 // TODO(darin): Figure out proper ownership of this instance.
92 HTMLDocumentView* document_view_; 90 HTMLDocumentView* document_view_;
93 URLResponsePtr response_; 91 URLResponsePtr response_;
94 ScopedDataPipeConsumerHandle response_body_stream_;
95 92
96 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); 93 DISALLOW_COPY_AND_ASSIGN(HTMLViewer);
97 }; 94 };
98 95
99 void NavigatorImpl::Navigate( 96 void NavigatorImpl::Navigate(
100 uint32_t node_id, 97 uint32_t node_id,
101 navigation::NavigationDetailsPtr navigation_details, 98 navigation::NavigationDetailsPtr navigation_details,
102 navigation::ResponseDetailsPtr response_details) { 99 navigation::ResponseDetailsPtr response_details) {
103 printf("In HTMLViewer, rendering url: %s\n", 100 printf("In HTMLViewer, rendering url: %s\n",
104 response_details->response->url.data()); 101 response_details->response->url.data());
105 viewer_->Load(response_details->response.Pass(), 102 viewer_->Load(response_details->response.Pass());
106 response_details->response_body_stream.Pass());
107 } 103 }
108 104
109 } 105 }
110 106
111 // static 107 // static
112 ApplicationDelegate* ApplicationDelegate::Create() { 108 ApplicationDelegate* ApplicationDelegate::Create() {
113 return new examples::HTMLViewer; 109 return new examples::HTMLViewer;
114 } 110 }
115 111
116 } 112 }
OLDNEW
« no previous file with comments | « mojo/examples/html_viewer/html_document_view.cc ('k') | mojo/examples/html_viewer/weburlloader_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698