| Index: content/renderer/fetchers/web_url_loader_client_impl.cc
|
| diff --git a/content/renderer/fetchers/web_url_loader_client_impl.cc b/content/renderer/fetchers/web_url_loader_client_impl.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..847a167928fd1c540763e7c569b3cae0543f095b
|
| --- /dev/null
|
| +++ b/content/renderer/fetchers/web_url_loader_client_impl.cc
|
| @@ -0,0 +1,75 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/renderer/fetchers/web_url_loader_client_impl.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "third_party/WebKit/public/platform/WebURLError.h"
|
| +#include "third_party/WebKit/public/platform/WebURLLoader.h"
|
| +#include "third_party/WebKit/public/platform/WebURLResponse.h"
|
| +
|
| +namespace content {
|
| +
|
| +WebURLLoaderClientImpl::WebURLLoaderClientImpl()
|
| + : completed_(false)
|
| + , status_(LOADING) {
|
| +}
|
| +
|
| +WebURLLoaderClientImpl::~WebURLLoaderClientImpl() {
|
| +}
|
| +
|
| +void WebURLLoaderClientImpl::didReceiveResponse(
|
| + blink::WebURLLoader* loader, const blink::WebURLResponse& response) {
|
| + DCHECK(!completed_);
|
| + response_ = response;
|
| +}
|
| +
|
| +void WebURLLoaderClientImpl::didReceiveData(
|
| + blink::WebURLLoader* loader,
|
| + const char* data,
|
| + int data_length,
|
| + int encoded_data_length) {
|
| + DCHECK(!completed_);
|
| + DCHECK(data_length > 0);
|
| +
|
| + data_.append(data, data_length);
|
| +}
|
| +
|
| +void WebURLLoaderClientImpl::didReceiveCachedMetadata(
|
| + blink::WebURLLoader* loader,
|
| + const char* data,
|
| + int data_length) {
|
| + DCHECK(!completed_);
|
| + DCHECK(data_length > 0);
|
| +
|
| + metadata_.assign(data, data_length);
|
| +}
|
| +
|
| +void WebURLLoaderClientImpl::didFinishLoading(
|
| + blink::WebURLLoader* loader,
|
| + double finishTime,
|
| + int64_t total_encoded_data_length) {
|
| + OnLoadCompleteInternal(LOAD_SUCCEEDED);
|
| +}
|
| +
|
| +void WebURLLoaderClientImpl::didFail(blink::WebURLLoader* loader,
|
| + const blink::WebURLError& error) {
|
| + OnLoadCompleteInternal(LOAD_FAILED);
|
| +}
|
| +
|
| +void WebURLLoaderClientImpl::Cancel() {
|
| + OnLoadCompleteInternal(LOAD_FAILED);
|
| +}
|
| +
|
| +void WebURLLoaderClientImpl::OnLoadCompleteInternal(LoadStatus status) {
|
| + DCHECK(!completed_);
|
| + DCHECK(status_ == LOADING);
|
| +
|
| + completed_ = true;
|
| + status_ = status;
|
| +
|
| + OnLoadComplete();
|
| +}
|
| +
|
| +} // namespace content
|
|
|