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 #include "webkit/glue/resource_fetcher.h" | 5 #include "webkit/glue/resource_fetcher.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
9 #include "base/timer.h" | 10 #include "base/timer.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
13 #include "webkit/glue/unittest_test_server.h" | 14 #include "webkit/glue/unittest_test_server.h" |
14 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 15 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
15 #include "webkit/tools/test_shell/test_shell_test.h" | 16 #include "webkit/tools/test_shell/test_shell_test.h" |
16 | 17 |
17 using WebKit::WebFrame; | 18 using WebKit::WebFrame; |
(...skipping 17 matching lines...) Expand all Loading... |
35 : completed_(false), | 36 : completed_(false), |
36 timed_out_(false) { | 37 timed_out_(false) { |
37 // Start a repeating timer waiting for the download to complete. The | 38 // Start a repeating timer waiting for the download to complete. The |
38 // callback has to be a static function, so we hold on to our instance. | 39 // callback has to be a static function, so we hold on to our instance. |
39 FetcherDelegate::instance_ = this; | 40 FetcherDelegate::instance_ = this; |
40 StartTimer(); | 41 StartTimer(); |
41 } | 42 } |
42 | 43 |
43 virtual ~FetcherDelegate() {} | 44 virtual ~FetcherDelegate() {} |
44 | 45 |
45 ResourceFetcher::Callback* NewCallback() { | 46 ResourceFetcher::Callback NewCallback() { |
46 return ::NewCallback(this, &FetcherDelegate::OnURLFetchComplete); | 47 return base::Bind(&FetcherDelegate::OnURLFetchComplete, |
| 48 base::Unretained(this)); |
47 } | 49 } |
48 | 50 |
49 virtual void OnURLFetchComplete(const WebURLResponse& response, | 51 virtual void OnURLFetchComplete(const WebURLResponse& response, |
50 const std::string& data) { | 52 const std::string& data) { |
51 response_ = response; | 53 response_ = response; |
52 data_ = data; | 54 data_ = data; |
53 completed_ = true; | 55 completed_ = true; |
54 timer_.Stop(); | 56 timer_.Stop(); |
55 MessageLoop::current()->Quit(); | 57 MessageLoop::current()->Quit(); |
56 } | 58 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 scoped_ptr<ResourceFetcher> fetcher(new ResourceFetcherWithTimeout( | 208 scoped_ptr<ResourceFetcher> fetcher(new ResourceFetcherWithTimeout( |
207 url, frame, WebURLRequest::TargetIsMainFrame, | 209 url, frame, WebURLRequest::TargetIsMainFrame, |
208 0, delegate->NewCallback())); | 210 0, delegate->NewCallback())); |
209 delegate->SetFetcher(fetcher.release()); | 211 delegate->SetFetcher(fetcher.release()); |
210 | 212 |
211 delegate->WaitForResponse(); | 213 delegate->WaitForResponse(); |
212 EXPECT_FALSE(delegate->timed_out()); | 214 EXPECT_FALSE(delegate->timed_out()); |
213 } | 215 } |
214 | 216 |
215 } // namespace | 217 } // namespace |
OLD | NEW |