OLD | NEW |
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 "components/nacl/renderer/file_downloader.h" | 5 #include "components/nacl/renderer/file_downloader.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "components/nacl/renderer/nexe_load_manager.h" | 10 #include "components/nacl/renderer/nexe_load_manager.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 http_status_code_ = response.httpStatusCode(); | 43 http_status_code_ = response.httpStatusCode(); |
44 if (http_status_code_ != 200) | 44 if (http_status_code_ != 200) |
45 status_ = FAILED; | 45 status_ = FAILED; |
46 | 46 |
47 // Set -1 if the content length is unknown. Set before issuing callback. | 47 // Set -1 if the content length is unknown. Set before issuing callback. |
48 total_bytes_to_be_received_ = response.expectedContentLength(); | 48 total_bytes_to_be_received_ = response.expectedContentLength(); |
49 if (!progress_cb_.is_null()) | 49 if (!progress_cb_.is_null()) |
50 progress_cb_.Run(total_bytes_received_, total_bytes_to_be_received_); | 50 progress_cb_.Run(total_bytes_received_, total_bytes_to_be_received_); |
51 } | 51 } |
52 | 52 |
53 void FileDownloader::didReceiveData( | 53 void FileDownloader::didReceiveData(blink::WebURLLoader* loader, |
54 blink::WebURLLoader* loader, | 54 const char* data, |
55 const char* data, | 55 int data_length, |
56 int data_length, | 56 int encoded_data_length, |
57 int encoded_data_length) { | 57 int encoded_body_length) { |
58 if (status_ == SUCCESS) { | 58 if (status_ == SUCCESS) { |
59 if (file_.Write(total_bytes_received_, data, data_length) == -1) { | 59 if (file_.Write(total_bytes_received_, data, data_length) == -1) { |
60 status_ = FAILED; | 60 status_ = FAILED; |
61 return; | 61 return; |
62 } | 62 } |
63 total_bytes_received_ += data_length; | 63 total_bytes_received_ += data_length; |
64 if (!progress_cb_.is_null()) | 64 if (!progress_cb_.is_null()) |
65 progress_cb_.Run(total_bytes_received_, total_bytes_to_be_received_); | 65 progress_cb_.Run(total_bytes_received_, total_bytes_to_be_received_); |
66 } | 66 } |
67 } | 67 } |
(...skipping 30 matching lines...) Expand all Loading... |
98 | 98 |
99 // Delete url_loader to prevent didFinishLoading from being called, which | 99 // Delete url_loader to prevent didFinishLoading from being called, which |
100 // some implementations of blink::WebURLLoader will do after calling didFail. | 100 // some implementations of blink::WebURLLoader will do after calling didFail. |
101 url_loader_.reset(); | 101 url_loader_.reset(); |
102 | 102 |
103 status_cb_.Run(status_, std::move(file_), http_status_code_); | 103 status_cb_.Run(status_, std::move(file_), http_status_code_); |
104 delete this; | 104 delete this; |
105 } | 105 } |
106 | 106 |
107 } // namespace nacl | 107 } // namespace nacl |
OLD | NEW |