Update V8 to version 4.6.61.
[chromium-blink-merge.git] / content / renderer / fetchers / web_url_loader_client_impl.h
blobd028b76ccbbbe1ef1fe8456fcf2085647bc11e4a
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.
5 #ifndef CONTENT_RENDERER_FETCHERS_WEB_URL_LOADER_CLIENT_IMPL_H_
6 #define CONTENT_RENDERER_FETCHERS_WEB_URL_LOADER_CLIENT_IMPL_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
12 #include "third_party/WebKit/public/platform/WebURLResponse.h"
14 namespace blink {
15 class WebURLLoader;
16 struct WebURLError;
19 namespace content {
21 class WebURLLoaderClientImpl : public blink::WebURLLoaderClient {
22 protected:
23 enum LoadStatus {
24 LOADING,
25 LOAD_FAILED,
26 LOAD_SUCCEEDED,
29 WebURLLoaderClientImpl();
30 virtual ~WebURLLoaderClientImpl();
32 virtual void Cancel();
34 bool completed() const { return completed_; }
35 const std::string& data() const { return data_; }
36 const blink::WebURLResponse& response() const { return response_; }
37 const std::string& metadata() const { return metadata_; }
38 LoadStatus status() const { return status_; }
40 virtual void OnLoadComplete() = 0;
42 private:
43 void OnLoadCompleteInternal(LoadStatus);
45 // WebWebURLLoaderClientImpl methods:
46 virtual void didReceiveResponse(
47 blink::WebURLLoader* loader, const blink::WebURLResponse& response);
48 virtual void didReceiveCachedMetadata(
49 blink::WebURLLoader* loader, const char* data, int data_length);
50 virtual void didReceiveData(
51 blink::WebURLLoader* loader,
52 const char* data,
53 int data_length,
54 int encoded_data_length);
55 virtual void didFinishLoading(
56 blink::WebURLLoader* loader,
57 double finishTime,
58 int64_t total_encoded_data_length);
59 virtual void didFail(
60 blink::WebURLLoader* loader, const blink::WebURLError& error);
62 private:
63 // Set to true once the request is complete.
64 bool completed_;
66 // Buffer to hold the content from the server.
67 std::string data_;
69 // A copy of the original resource response.
70 blink::WebURLResponse response_;
72 // Buffer to hold metadata from the cache.
73 std::string metadata_;
75 LoadStatus status_;
77 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderClientImpl);
80 } // namespace content
82 #endif // CONTENT_RENDERER_FETCHERS_WEB_URL_LOADER_CLIENT_IMPL_H_