OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/renderer/fetchers/resource_fetcher.h" | 5 #include "content/renderer/fetchers/resource_fetcher.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/WebKit/public/platform/Platform.h" | 8 #include "third_party/WebKit/public/platform/Platform.h" |
9 #include "third_party/WebKit/public/platform/WebURL.h" | 9 #include "third_party/WebKit/public/platform/WebURL.h" |
10 #include "third_party/WebKit/public/platform/WebURLError.h" | 10 #include "third_party/WebKit/public/platform/WebURLError.h" |
11 #include "third_party/WebKit/public/platform/WebURLLoader.h" | 11 #include "third_party/WebKit/public/platform/WebURLLoader.h" |
12 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 12 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
13 #include "third_party/WebKit/public/web/WebDocument.h" | 13 #include "third_party/WebKit/public/web/WebDocument.h" |
14 #include "third_party/WebKit/public/web/WebFrame.h" | 14 #include "third_party/WebKit/public/web/WebFrame.h" |
15 #include "third_party/WebKit/public/web/WebKit.h" | 15 #include "third_party/WebKit/public/web/WebKit.h" |
16 | 16 |
17 using base::TimeDelta; | 17 using base::TimeDelta; |
18 using WebKit::WebFrame; | 18 using blink::WebFrame; |
19 using WebKit::WebURLError; | 19 using blink::WebURLError; |
20 using WebKit::WebURLLoader; | 20 using blink::WebURLLoader; |
21 using WebKit::WebURLRequest; | 21 using blink::WebURLRequest; |
22 using WebKit::WebURLResponse; | 22 using blink::WebURLResponse; |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 | 25 |
26 ResourceFetcher::ResourceFetcher(const GURL& url, WebFrame* frame, | 26 ResourceFetcher::ResourceFetcher(const GURL& url, WebFrame* frame, |
27 WebURLRequest::TargetType target_type, | 27 WebURLRequest::TargetType target_type, |
28 const Callback& callback) | 28 const Callback& callback) |
29 : url_(url), | 29 : url_(url), |
30 target_type_(target_type), | 30 target_type_(target_type), |
31 completed_(false), | 31 completed_(false), |
32 callback_(callback) { | 32 callback_(callback) { |
(...skipping 14 matching lines...) Expand all Loading... |
47 completed_ = true; | 47 completed_ = true; |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 void ResourceFetcher::Start(WebFrame* frame) { | 51 void ResourceFetcher::Start(WebFrame* frame) { |
52 WebURLRequest request(url_); | 52 WebURLRequest request(url_); |
53 request.setTargetType(target_type_); | 53 request.setTargetType(target_type_); |
54 request.setFirstPartyForCookies(frame->document().firstPartyForCookies()); | 54 request.setFirstPartyForCookies(frame->document().firstPartyForCookies()); |
55 frame->dispatchWillSendRequest(request); | 55 frame->dispatchWillSendRequest(request); |
56 | 56 |
57 loader_.reset(WebKit::Platform::current()->createURLLoader()); | 57 loader_.reset(blink::Platform::current()->createURLLoader()); |
58 loader_->loadAsynchronously(request, this); | 58 loader_->loadAsynchronously(request, this); |
59 } | 59 } |
60 | 60 |
61 void ResourceFetcher::RunCallback(const WebURLResponse& response, | 61 void ResourceFetcher::RunCallback(const WebURLResponse& response, |
62 const std::string& data) { | 62 const std::string& data) { |
63 if (callback_.is_null()) | 63 if (callback_.is_null()) |
64 return; | 64 return; |
65 | 65 |
66 // Take a reference to the callback as running the callback may lead to our | 66 // Take a reference to the callback as running the callback may lead to our |
67 // destruction. | 67 // destruction. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 void ResourceFetcherWithTimeout::TimeoutFired() { | 138 void ResourceFetcherWithTimeout::TimeoutFired() { |
139 if (!completed_) { | 139 if (!completed_) { |
140 loader_->cancel(); | 140 loader_->cancel(); |
141 didFail(NULL, WebURLError()); | 141 didFail(NULL, WebURLError()); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 } // namespace content | 145 } // namespace content |
OLD | NEW |