| 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/callback.h" |
| 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" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // testing infrastructure (test_shell) can generate spurious calls to the | 65 // testing infrastructure (test_shell) can generate spurious calls to the |
| 66 // MessageLoop's Quit method. | 66 // MessageLoop's Quit method. |
| 67 void WaitForResponse() { | 67 void WaitForResponse() { |
| 68 while (!completed() && !timed_out()) | 68 while (!completed() && !timed_out()) |
| 69 MessageLoop::current()->Run(); | 69 MessageLoop::current()->Run(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void StartTimer() { | 72 void StartTimer() { |
| 73 timer_.Start(base::TimeDelta::FromMilliseconds(kMaxWaitTimeMs), | 73 timer_.Start(base::TimeDelta::FromMilliseconds(kMaxWaitTimeMs), |
| 74 this, | 74 this, |
| 75 &FetcherDelegate::TimerFired); | 75 &FetcherDelegate::TimerFired, |
| 76 FROM_HERE); |
| 76 } | 77 } |
| 77 | 78 |
| 78 void TimerFired() { | 79 void TimerFired() { |
| 79 ASSERT_FALSE(completed_); | 80 ASSERT_FALSE(completed_); |
| 80 | 81 |
| 81 timed_out_ = true; | 82 timed_out_ = true; |
| 82 MessageLoop::current()->Quit(); | 83 MessageLoop::current()->Quit(); |
| 83 FAIL() << "fetch timed out"; | 84 FAIL() << "fetch timed out"; |
| 84 } | 85 } |
| 85 | 86 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 scoped_ptr<ResourceFetcher> fetcher(new ResourceFetcherWithTimeout( | 206 scoped_ptr<ResourceFetcher> fetcher(new ResourceFetcherWithTimeout( |
| 206 url, frame, WebURLRequest::TargetIsMainFrame, | 207 url, frame, WebURLRequest::TargetIsMainFrame, |
| 207 0, delegate->NewCallback())); | 208 0, delegate->NewCallback())); |
| 208 delegate->SetFetcher(fetcher.release()); | 209 delegate->SetFetcher(fetcher.release()); |
| 209 | 210 |
| 210 delegate->WaitForResponse(); | 211 delegate->WaitForResponse(); |
| 211 EXPECT_FALSE(delegate->timed_out()); | 212 EXPECT_FALSE(delegate->timed_out()); |
| 212 } | 213 } |
| 213 | 214 |
| 214 } // namespace | 215 } // namespace |
| OLD | NEW |