| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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( |
| 29 blink::WebURLLoader* loader, | 29 blink::WebURLLoader* loader, |
| 30 const char* data, | 30 const char* data, |
| 31 int data_length, | 31 int data_length, |
| 32 int encoded_data_length) { | 32 int encoded_data_length) { |
| 33 DCHECK(!completed_); | 33 // The AssociatedURLLoader will continue after a load failure. |
| 34 // For example, for an Access Control error. |
| 35 if (completed_) |
| 36 return; |
| 34 DCHECK(data_length > 0); | 37 DCHECK(data_length > 0); |
| 35 | 38 |
| 36 data_.append(data, data_length); | 39 data_.append(data, data_length); |
| 37 } | 40 } |
| 38 | 41 |
| 39 void WebURLLoaderClientImpl::didReceiveCachedMetadata( | 42 void WebURLLoaderClientImpl::didReceiveCachedMetadata( |
| 40 blink::WebURLLoader* loader, | 43 blink::WebURLLoader* loader, |
| 41 const char* data, | 44 const char* data, |
| 42 int data_length) { | 45 int data_length) { |
| 43 DCHECK(!completed_); | 46 DCHECK(!completed_); |
| 44 DCHECK(data_length > 0); | 47 DCHECK(data_length > 0); |
| 45 | 48 |
| 46 metadata_.assign(data, data_length); | 49 metadata_.assign(data, data_length); |
| 47 } | 50 } |
| 48 | 51 |
| 49 void WebURLLoaderClientImpl::didFinishLoading( | 52 void WebURLLoaderClientImpl::didFinishLoading( |
| 50 blink::WebURLLoader* loader, | 53 blink::WebURLLoader* loader, |
| 51 double finishTime, | 54 double finishTime, |
| 52 int64_t total_encoded_data_length) { | 55 int64_t total_encoded_data_length) { |
| 56 // The AssociatedURLLoader will continue after a load failure. |
| 57 // For example, for an Access Control error. |
| 58 if (completed_) |
| 59 return; |
| 53 OnLoadCompleteInternal(LOAD_SUCCEEDED); | 60 OnLoadCompleteInternal(LOAD_SUCCEEDED); |
| 54 } | 61 } |
| 55 | 62 |
| 56 void WebURLLoaderClientImpl::didFail(blink::WebURLLoader* loader, | 63 void WebURLLoaderClientImpl::didFail(blink::WebURLLoader* loader, |
| 57 const blink::WebURLError& error) { | 64 const blink::WebURLError& error) { |
| 58 OnLoadCompleteInternal(LOAD_FAILED); | 65 OnLoadCompleteInternal(LOAD_FAILED); |
| 59 } | 66 } |
| 60 | 67 |
| 61 void WebURLLoaderClientImpl::Cancel() { | 68 void WebURLLoaderClientImpl::Cancel() { |
| 62 OnLoadCompleteInternal(LOAD_FAILED); | 69 OnLoadCompleteInternal(LOAD_FAILED); |
| 63 } | 70 } |
| 64 | 71 |
| 65 void WebURLLoaderClientImpl::OnLoadCompleteInternal(LoadStatus status) { | 72 void WebURLLoaderClientImpl::OnLoadCompleteInternal(LoadStatus status) { |
| 66 DCHECK(!completed_); | 73 DCHECK(!completed_); |
| 67 DCHECK(status_ == LOADING); | 74 DCHECK(status_ == LOADING); |
| 68 | 75 |
| 69 completed_ = true; | 76 completed_ = true; |
| 70 status_ = status; | 77 status_ = status; |
| 71 | 78 |
| 72 OnLoadComplete(); | 79 OnLoadComplete(); |
| 73 } | 80 } |
| 74 | 81 |
| 75 } // namespace content | 82 } // namespace content |
| OLD | NEW |