blob: 1113862873fd21f23b7dcb825f59e79c38258834 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// Copyright (c) 2011 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.
#ifndef CONTENT_RENDERER_FETCHERS_WEB_URL_LOADER_CLIENT_IMPL_H_
#define CONTENT_RENDERER_FETCHERS_WEB_URL_LOADER_CLIENT_IMPL_H_
#include <string>
#include "base/memory/scoped_ptr.h"
#include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
#include "third_party/WebKit/public/platform/WebURLResponse.h"
namespace blink {
class WebURLLoader;
struct WebURLError;
}
namespace content {
class WebURLLoaderClientImpl : public blink::WebURLLoaderClient {
protected:
enum LoadStatus {
LOADING,
LOAD_FAILED,
LOAD_SUCCEEDED,
};
WebURLLoaderClientImpl();
virtual ~WebURLLoaderClientImpl();
virtual void Cancel();
bool completed() const { return completed_; }
const std::string& data() const { return data_; }
const blink::WebURLResponse& response() const { return response_; }
const std::string& metadata() const { return metadata_; }
LoadStatus status() const { return status_; }
virtual void OnLoadComplete() = 0;
private:
void OnLoadCompleteInternal(LoadStatus);
// WebWebURLLoaderClientImpl methods:
virtual void didReceiveResponse(
blink::WebURLLoader* loader, const blink::WebURLResponse& response);
virtual void didReceiveCachedMetadata(
blink::WebURLLoader* loader, const char* data, int data_length);
virtual void didReceiveData(
blink::WebURLLoader* loader,
const char* data,
int data_length,
int encoded_data_length);
virtual void didFinishLoading(
blink::WebURLLoader* loader,
double finishTime,
int64_t total_encoded_data_length);
virtual void didFail(
blink::WebURLLoader* loader, const blink::WebURLError& error);
private:
// Set to true once the request is complete.
bool completed_;
// Buffer to hold the content from the server.
std::string data_;
// A copy of the original resource response.
blink::WebURLResponse response_;
// Buffer to hold metadata from the cache.
std::string metadata_;
LoadStatus status_;
DISALLOW_COPY_AND_ASSIGN(WebURLLoaderClientImpl);
};
} // namespace content
#endif // CONTENT_RENDERER_FETCHERS_URL_LOADER_CLIENT_H_
|