Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: content/renderer/fetchers/resource_fetcher_impl.h

Issue 840553003: Use a FrameAssociatedLoader when downloading image resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
15 #include "content/public/renderer/resource_fetcher.h" 15 #include "content/public/renderer/resource_fetcher.h"
16 #include "content/renderer/fetchers/web_url_loader_client_impl.h" 16 #include "content/renderer/fetchers/web_url_loader_client_impl.h"
17 #include "third_party/WebKit/public/platform/WebURLRequest.h" 17 #include "third_party/WebKit/public/platform/WebURLRequest.h"
18 #include "third_party/WebKit/public/platform/WebURLResponse.h" 18 #include "third_party/WebKit/public/platform/WebURLResponse.h"
19 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h"
19 20
20 class GURL; 21 class GURL;
21 22
22 namespace blink { 23 namespace blink {
23 class WebFrame; 24 class WebFrame;
24 class WebURLLoader; 25 class WebURLLoader;
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 void SetMethod(const std::string& method) override; 34 void SetMethod(const std::string& method) override;
35 void SetBody(const std::string& body) override; 35 void SetBody(const std::string& body) override;
36 void SetHeader(const std::string& header, const std::string& value) override; 36 void SetHeader(const std::string& header, const std::string& value) override;
37 void SetSkipServiceWorker(bool skip_service_worker) override;
38 void SetLoaderOptions(const blink::WebURLLoaderOptions& options) override;
37 void Start(blink::WebFrame* frame, 39 void Start(blink::WebFrame* frame,
38 blink::WebURLRequest::RequestContext request_context, 40 blink::WebURLRequest::RequestContext request_context,
39 blink::WebURLRequest::FrameType frame_type, 41 blink::WebURLRequest::FrameType frame_type,
40 LoaderType loader_type, 42 LoaderType loader_type,
41 const Callback& callback) override; 43 const Callback& callback) override;
42 void SetTimeout(const base::TimeDelta& timeout) override; 44 void SetTimeout(const base::TimeDelta& timeout) override;
43 45
44 private: 46 private:
45 friend class ResourceFetcher; 47 friend class ResourceFetcher;
46 48
47 explicit ResourceFetcherImpl(const GURL& url); 49 explicit ResourceFetcherImpl(const GURL& url);
48 50
49 virtual ~ResourceFetcherImpl(); 51 virtual ~ResourceFetcherImpl();
50 52
51 // Callback for timer that limits how long we wait for the server. If this 53 // Callback for timer that limits how long we wait for the server. If this
52 // timer fires and the request hasn't completed, we kill the request. 54 // timer fires and the request hasn't completed, we kill the request.
53 void TimeoutFired(); 55 void TimeoutFired();
54 56
55 // WebURLLoaderClientImpl methods: 57 // WebURLLoaderClientImpl methods:
56 void OnLoadComplete() override; 58 void OnLoadComplete() override;
57 void Cancel() override; 59 void Cancel() override;
58 60
59 scoped_ptr<blink::WebURLLoader> loader_; 61 scoped_ptr<blink::WebURLLoader> loader_;
60 62
63 // Options to send to the loader.
64 blink::WebURLLoaderOptions options_;
65
61 // Request to send. Released once Start() is called. 66 // Request to send. Released once Start() is called.
62 blink::WebURLRequest request_; 67 blink::WebURLRequest request_;
63 68
64 // Callback when we're done. 69 // Callback when we're done.
65 Callback callback_; 70 Callback callback_;
66 71
67 // Limit how long to wait for the server. 72 // Limit how long to wait for the server.
68 base::OneShotTimer<ResourceFetcherImpl> timeout_timer_; 73 base::OneShotTimer<ResourceFetcherImpl> timeout_timer_;
69 74
70 DISALLOW_COPY_AND_ASSIGN(ResourceFetcherImpl); 75 DISALLOW_COPY_AND_ASSIGN(ResourceFetcherImpl);
71 }; 76 };
72 77
73 } // namespace content 78 } // namespace content
74 79
75 #endif // CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ 80 #endif // CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698