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 "content/renderer/fetchers/web_url_loader_client_impl.h" | 5 #include "content/renderer/fetchers/web_url_loader_client_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/WebKit/public/platform/WebURLError.h" | 8 #include "third_party/WebKit/public/platform/WebURLError.h" |
9 #include "third_party/WebKit/public/platform/WebURLLoader.h" | 9 #include "third_party/WebKit/public/platform/WebURLLoader.h" |
10 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 10 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 WebURLLoaderClientImpl::WebURLLoaderClientImpl() | 14 WebURLLoaderClientImpl::WebURLLoaderClientImpl() |
15 : completed_(false) | 15 : completed_(false) |
16 , status_(LOADING) { | 16 , status_(LOADING) { |
17 } | 17 } |
18 | 18 |
19 WebURLLoaderClientImpl::~WebURLLoaderClientImpl() { | 19 WebURLLoaderClientImpl::~WebURLLoaderClientImpl() { |
20 } | 20 } |
21 | 21 |
22 void WebURLLoaderClientImpl::didReceiveResponse( | 22 void WebURLLoaderClientImpl::didReceiveResponse( |
23 blink::WebURLLoader* loader, const blink::WebURLResponse& response) { | 23 blink::WebURLLoader* loader, const blink::WebURLResponse& response) { |
24 DCHECK(!completed_); | 24 DCHECK(!completed_); |
25 response_ = response; | 25 response_ = response; |
26 } | 26 } |
27 | 27 |
28 void WebURLLoaderClientImpl::didReceiveData( | 28 void WebURLLoaderClientImpl::didReceiveData(blink::WebURLLoader* loader, |
29 blink::WebURLLoader* loader, | 29 const char* data, |
30 const char* data, | 30 int data_length, |
31 int data_length, | 31 int encoded_data_length, |
32 int encoded_data_length) { | 32 int encoded_body_length) { |
33 // The AssociatedURLLoader will continue after a load failure. | 33 // The AssociatedURLLoader will continue after a load failure. |
34 // For example, for an Access Control error. | 34 // For example, for an Access Control error. |
35 if (completed_) | 35 if (completed_) |
36 return; | 36 return; |
37 DCHECK(data_length > 0); | 37 DCHECK(data_length > 0); |
38 | 38 |
39 data_.append(data, data_length); | 39 data_.append(data, data_length); |
40 } | 40 } |
41 | 41 |
42 void WebURLLoaderClientImpl::didReceiveCachedMetadata( | 42 void WebURLLoaderClientImpl::didReceiveCachedMetadata( |
(...skipping 30 matching lines...) Expand all Loading... |
73 DCHECK(!completed_); | 73 DCHECK(!completed_); |
74 DCHECK(status_ == LOADING); | 74 DCHECK(status_ == LOADING); |
75 | 75 |
76 completed_ = true; | 76 completed_ = true; |
77 status_ = status; | 77 status_ = status; |
78 | 78 |
79 OnLoadComplete(); | 79 OnLoadComplete(); |
80 } | 80 } |
81 | 81 |
82 } // namespace content | 82 } // namespace content |
OLD | NEW |