blob: 70fb7da405851be41d15a26ad6ff520b1b006164 (
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
83
84
|
// 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 <stdint.h>
#include <string>
#include "base/macros.h"
#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();
~WebURLLoaderClientImpl() override;
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:
void didReceiveResponse(blink::WebURLLoader* loader,
const blink::WebURLResponse& response) override;
void didReceiveCachedMetadata(blink::WebURLLoader* loader,
const char* data,
int data_length) override;
void didReceiveData(blink::WebURLLoader* loader,
const char* data,
int data_length,
int encoded_data_length) override;
void didFinishLoading(blink::WebURLLoader* loader,
double finishTime,
int64_t total_encoded_data_length) override;
void didFail(blink::WebURLLoader* loader,
const blink::WebURLError& error) override;
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_WEB_URL_LOADER_CLIENT_IMPL_H_
|