| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ | 5 #ifndef CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ |
| 6 #define CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ | 6 #define CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 class WebURLLoader; | 24 class WebURLLoader; |
| 25 struct WebURLError; | 25 struct WebURLError; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 class ResourceFetcherImpl : public ResourceFetcher, | 30 class ResourceFetcherImpl : public ResourceFetcher, |
| 31 public WebURLLoaderClientImpl { | 31 public WebURLLoaderClientImpl { |
| 32 public: | 32 public: |
| 33 // ResourceFetcher implementation: | 33 // ResourceFetcher implementation: |
| 34 virtual void SetMethod(const std::string& method) override; | 34 void SetMethod(const std::string& method) override; |
| 35 virtual void SetBody(const std::string& body) override; | 35 void SetBody(const std::string& body) override; |
| 36 virtual void SetHeader(const std::string& header, | 36 void SetHeader(const std::string& header, const std::string& value) override; |
| 37 const std::string& value) override; | 37 void Start(blink::WebFrame* frame, |
| 38 virtual void Start(blink::WebFrame* frame, | 38 blink::WebURLRequest::RequestContext request_context, |
| 39 blink::WebURLRequest::RequestContext request_context, | 39 blink::WebURLRequest::FrameType frame_type, |
| 40 blink::WebURLRequest::FrameType frame_type, | 40 LoaderType loader_type, |
| 41 LoaderType loader_type, | 41 const Callback& callback) override; |
| 42 const Callback& callback) override; | 42 void SetTimeout(const base::TimeDelta& timeout) override; |
| 43 virtual void SetTimeout(const base::TimeDelta& timeout) override; | |
| 44 | 43 |
| 45 private: | 44 private: |
| 46 friend class ResourceFetcher; | 45 friend class ResourceFetcher; |
| 47 | 46 |
| 48 explicit ResourceFetcherImpl(const GURL& url); | 47 explicit ResourceFetcherImpl(const GURL& url); |
| 49 | 48 |
| 50 virtual ~ResourceFetcherImpl(); | 49 virtual ~ResourceFetcherImpl(); |
| 51 | 50 |
| 52 // Callback for timer that limits how long we wait for the server. If this | 51 // Callback for timer that limits how long we wait for the server. If this |
| 53 // timer fires and the request hasn't completed, we kill the request. | 52 // timer fires and the request hasn't completed, we kill the request. |
| 54 void TimeoutFired(); | 53 void TimeoutFired(); |
| 55 | 54 |
| 56 // WebURLLoaderClientImpl methods: | 55 // WebURLLoaderClientImpl methods: |
| 57 virtual void OnLoadComplete() override; | 56 void OnLoadComplete() override; |
| 58 virtual void Cancel() override; | 57 void Cancel() override; |
| 59 | 58 |
| 60 scoped_ptr<blink::WebURLLoader> loader_; | 59 scoped_ptr<blink::WebURLLoader> loader_; |
| 61 | 60 |
| 62 // Request to send. Released once Start() is called. | 61 // Request to send. Released once Start() is called. |
| 63 blink::WebURLRequest request_; | 62 blink::WebURLRequest request_; |
| 64 | 63 |
| 65 // Callback when we're done. | 64 // Callback when we're done. |
| 66 Callback callback_; | 65 Callback callback_; |
| 67 | 66 |
| 68 // Limit how long to wait for the server. | 67 // Limit how long to wait for the server. |
| 69 base::OneShotTimer<ResourceFetcherImpl> timeout_timer_; | 68 base::OneShotTimer<ResourceFetcherImpl> timeout_timer_; |
| 70 | 69 |
| 71 DISALLOW_COPY_AND_ASSIGN(ResourceFetcherImpl); | 70 DISALLOW_COPY_AND_ASSIGN(ResourceFetcherImpl); |
| 72 }; | 71 }; |
| 73 | 72 |
| 74 } // namespace content | 73 } // namespace content |
| 75 | 74 |
| 76 #endif // CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ | 75 #endif // CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ |
| OLD | NEW |