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