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

Side by Side Diff: mojo/examples/png_viewer/png_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
« no previous file with comments | « mojo/examples/html_viewer/weburlloader_impl.cc ('k') | mojo/examples/wget/wget.cc » ('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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/strings/string_tokenizer.h" 7 #include "base/strings/string_tokenizer.h"
8 #include "mojo/examples/media_viewer/media_viewer.mojom.h" 8 #include "mojo/examples/media_viewer/media_viewer.mojom.h"
9 #include "mojo/public/cpp/application/application_connection.h" 9 #include "mojo/public/cpp/application/application_connection.h"
10 #include "mojo/public/cpp/application/application_delegate.h" 10 #include "mojo/public/cpp/application/application_delegate.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 uint32_t node_id, 56 uint32_t node_id,
57 navigation::NavigationDetailsPtr navigation_details, 57 navigation::NavigationDetailsPtr navigation_details,
58 navigation::ResponseDetailsPtr response_details) OVERRIDE { 58 navigation::ResponseDetailsPtr response_details) OVERRIDE {
59 int content_length = GetContentLength(response_details->response->headers); 59 int content_length = GetContentLength(response_details->response->headers);
60 unsigned char* data = new unsigned char[content_length]; 60 unsigned char* data = new unsigned char[content_length];
61 unsigned char* buf = data; 61 unsigned char* buf = data;
62 uint32_t bytes_remaining = content_length; 62 uint32_t bytes_remaining = content_length;
63 uint32_t num_bytes = bytes_remaining; 63 uint32_t num_bytes = bytes_remaining;
64 while (bytes_remaining > 0) { 64 while (bytes_remaining > 0) {
65 MojoResult result = ReadDataRaw( 65 MojoResult result = ReadDataRaw(
66 response_details->response_body_stream.get(), 66 response_details->response->body.get(),
67 buf, 67 buf,
68 &num_bytes, 68 &num_bytes,
69 MOJO_READ_DATA_FLAG_NONE); 69 MOJO_READ_DATA_FLAG_NONE);
70 if (result == MOJO_RESULT_SHOULD_WAIT) { 70 if (result == MOJO_RESULT_SHOULD_WAIT) {
71 Wait(response_details->response_body_stream.get(), 71 Wait(response_details->response->body.get(),
72 MOJO_HANDLE_SIGNAL_READABLE, 72 MOJO_HANDLE_SIGNAL_READABLE,
73 MOJO_DEADLINE_INDEFINITE); 73 MOJO_DEADLINE_INDEFINITE);
74 } else if (result == MOJO_RESULT_OK) { 74 } else if (result == MOJO_RESULT_OK) {
75 buf += num_bytes; 75 buf += num_bytes;
76 num_bytes = bytes_remaining -= num_bytes; 76 num_bytes = bytes_remaining -= num_bytes;
77 } else { 77 } else {
78 break; 78 break;
79 } 79 }
80 } 80 }
81 81
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 210
211 } // namespace examples 211 } // namespace examples
212 212
213 // static 213 // static
214 ApplicationDelegate* ApplicationDelegate::Create() { 214 ApplicationDelegate* ApplicationDelegate::Create() {
215 return new examples::PNGViewer; 215 return new examples::PNGViewer;
216 } 216 }
217 217
218 } // namespace mojo 218 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/examples/html_viewer/weburlloader_impl.cc ('k') | mojo/examples/wget/wget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698