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

Side by Side Diff: webkit/glue/resource_fetcher_unittest.cc

Issue 8550010: base::Bind() conversion for webkit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month 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 | Annotate | Revision Log
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 #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"
csilv 2011/11/21 21:26:31 add #include base/bind_helpers.h
dcheng 2011/11/21 22:04:16 Done.
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/timer.h" 9 #include "base/timer.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
13 #include "webkit/glue/unittest_test_server.h" 13 #include "webkit/glue/unittest_test_server.h"
14 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" 14 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
15 #include "webkit/tools/test_shell/test_shell_test.h" 15 #include "webkit/tools/test_shell/test_shell_test.h"
16 16
17 using WebKit::WebFrame; 17 using WebKit::WebFrame;
(...skipping 17 matching lines...) Expand all
35 : completed_(false), 35 : completed_(false),
36 timed_out_(false) { 36 timed_out_(false) {
37 // Start a repeating timer waiting for the download to complete. The 37 // 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. 38 // callback has to be a static function, so we hold on to our instance.
39 FetcherDelegate::instance_ = this; 39 FetcherDelegate::instance_ = this;
40 StartTimer(); 40 StartTimer();
41 } 41 }
42 42
43 virtual ~FetcherDelegate() {} 43 virtual ~FetcherDelegate() {}
44 44
45 ResourceFetcher::Callback* NewCallback() { 45 ResourceFetcher::Callback NewCallback() {
46 return ::NewCallback(this, &FetcherDelegate::OnURLFetchComplete); 46 return base::Bind(&FetcherDelegate::OnURLFetchComplete,
47 base::Unretained(this));
47 } 48 }
48 49
49 virtual void OnURLFetchComplete(const WebURLResponse& response, 50 virtual void OnURLFetchComplete(const WebURLResponse& response,
50 const std::string& data) { 51 const std::string& data) {
51 response_ = response; 52 response_ = response;
52 data_ = data; 53 data_ = data;
53 completed_ = true; 54 completed_ = true;
54 timer_.Stop(); 55 timer_.Stop();
55 MessageLoop::current()->Quit(); 56 MessageLoop::current()->Quit();
56 } 57 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 scoped_ptr<ResourceFetcher> fetcher(new ResourceFetcherWithTimeout( 207 scoped_ptr<ResourceFetcher> fetcher(new ResourceFetcherWithTimeout(
207 url, frame, WebURLRequest::TargetIsMainFrame, 208 url, frame, WebURLRequest::TargetIsMainFrame,
208 0, delegate->NewCallback())); 209 0, delegate->NewCallback()));
209 delegate->SetFetcher(fetcher.release()); 210 delegate->SetFetcher(fetcher.release());
210 211
211 delegate->WaitForResponse(); 212 delegate->WaitForResponse();
212 EXPECT_FALSE(delegate->timed_out()); 213 EXPECT_FALSE(delegate->timed_out());
213 } 214 }
214 215
215 } // namespace 216 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698