OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "native_client/src/trusted/plugin/file_downloader.h" | 5 #include "native_client/src/trusted/plugin/file_downloader.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "native_client/src/include/portability_io.h" | 10 #include "native_client/src/include/portability_io.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 if (streaming_to_file()) | 115 if (streaming_to_file()) |
116 start_notify = &FileDownloader::URLLoadStartNotify; | 116 start_notify = &FileDownloader::URLLoadStartNotify; |
117 else | 117 else |
118 start_notify = &FileDownloader::URLBufferStartNotify; | 118 start_notify = &FileDownloader::URLBufferStartNotify; |
119 | 119 |
120 // Request asynchronous download of the url providing an on-load callback. | 120 // Request asynchronous download of the url providing an on-load callback. |
121 // As long as this step is guaranteed to be asynchronous, we can call | 121 // As long as this step is guaranteed to be asynchronous, we can call |
122 // synchronously all other internal callbacks that eventually result in the | 122 // synchronously all other internal callbacks that eventually result in the |
123 // invocation of the user callback. The user code will not be reentered. | 123 // invocation of the user callback. The user code will not be reentered. |
124 pp::CompletionCallback onload_callback = | 124 pp::CompletionCallback onload_callback = |
125 callback_factory_.NewRequiredCallback(start_notify); | 125 callback_factory_.NewCallback(start_notify); |
126 int32_t pp_error = url_loader_.Open(url_request, onload_callback); | 126 int32_t pp_error = url_loader_.Open(url_request, onload_callback); |
127 PLUGIN_PRINTF(("FileDownloader::Open (pp_error=%"NACL_PRId32")\n", pp_error)); | 127 PLUGIN_PRINTF(("FileDownloader::Open (pp_error=%"NACL_PRId32")\n", pp_error)); |
128 CHECK(pp_error == PP_OK_COMPLETIONPENDING); | 128 CHECK(pp_error == PP_OK_COMPLETIONPENDING); |
129 return true; | 129 return true; |
130 } | 130 } |
131 | 131 |
132 int32_t FileDownloader::GetPOSIXFileDescriptor() { | 132 int32_t FileDownloader::GetPOSIXFileDescriptor() { |
133 if (!streaming_to_file()) { | 133 if (!streaming_to_file()) { |
134 return NACL_NO_FILE_DESC; | 134 return NACL_NO_FILE_DESC; |
135 } | 135 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 333 |
334 bool FileDownloader::streaming_to_file() const { | 334 bool FileDownloader::streaming_to_file() const { |
335 return (flags_ & DOWNLOAD_TO_BUFFER) == 0; | 335 return (flags_ & DOWNLOAD_TO_BUFFER) == 0; |
336 } | 336 } |
337 | 337 |
338 bool FileDownloader::streaming_to_buffer() const { | 338 bool FileDownloader::streaming_to_buffer() const { |
339 return (flags_ & DOWNLOAD_TO_BUFFER) == 1; | 339 return (flags_ & DOWNLOAD_TO_BUFFER) == 1; |
340 } | 340 } |
341 | 341 |
342 } // namespace plugin | 342 } // namespace plugin |
OLD | NEW |