OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 <unistd.h> | 5 #include <unistd.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 { | 309 { |
310 PausingHttpFetcherTestDelegate delegate; | 310 PausingHttpFetcherTestDelegate delegate; |
311 scoped_ptr<HttpFetcher> fetcher(this->NewLargeFetcher()); | 311 scoped_ptr<HttpFetcher> fetcher(this->NewLargeFetcher()); |
312 delegate.paused_ = false; | 312 delegate.paused_ = false; |
313 delegate.loop_ = loop; | 313 delegate.loop_ = loop; |
314 delegate.fetcher_ = fetcher.get(); | 314 delegate.fetcher_ = fetcher.get(); |
315 fetcher->set_delegate(&delegate); | 315 fetcher->set_delegate(&delegate); |
316 | 316 |
317 typename TestFixture::HttpServer server; | 317 typename TestFixture::HttpServer server; |
318 ASSERT_TRUE(server.started_); | 318 ASSERT_TRUE(server.started_); |
319 GSource* timeout_source_; | 319 |
320 timeout_source_ = g_timeout_source_new(0); // ms | 320 guint callback_id = g_timeout_add(500, UnpausingTimeoutCallback, &delegate); |
321 g_source_set_callback(timeout_source_, UnpausingTimeoutCallback, &delegate, | |
322 NULL); | |
323 g_source_attach(timeout_source_, NULL); | |
324 fetcher->BeginTransfer(this->BigUrl()); | 321 fetcher->BeginTransfer(this->BigUrl()); |
325 | 322 |
326 g_main_loop_run(loop); | 323 g_main_loop_run(loop); |
327 g_source_destroy(timeout_source_); | 324 g_source_remove(callback_id); |
328 } | 325 } |
329 g_main_loop_unref(loop); | 326 g_main_loop_unref(loop); |
330 } | 327 } |
331 | 328 |
332 namespace { | 329 namespace { |
333 class AbortingHttpFetcherTestDelegate : public HttpFetcherDelegate { | 330 class AbortingHttpFetcherTestDelegate : public HttpFetcherDelegate { |
334 public: | 331 public: |
335 virtual void ReceivedBytes(HttpFetcher* fetcher, | 332 virtual void ReceivedBytes(HttpFetcher* fetcher, |
336 const char* bytes, int length) {} | 333 const char* bytes, int length) {} |
337 virtual void TransferComplete(HttpFetcher* fetcher, bool successful) { | 334 virtual void TransferComplete(HttpFetcher* fetcher, bool successful) { |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 StartTransferArgs start_xfer_args = | 800 StartTransferArgs start_xfer_args = |
804 { fetcher.get(), LocalServerUrlForPath(this->SmallUrl()) }; | 801 { fetcher.get(), LocalServerUrlForPath(this->SmallUrl()) }; |
805 | 802 |
806 g_timeout_add(0, StartTransfer, &start_xfer_args); | 803 g_timeout_add(0, StartTransfer, &start_xfer_args); |
807 g_main_loop_run(loop); | 804 g_main_loop_run(loop); |
808 g_main_loop_unref(loop); | 805 g_main_loop_unref(loop); |
809 } | 806 } |
810 } | 807 } |
811 | 808 |
812 } // namespace chromeos_update_engine | 809 } // namespace chromeos_update_engine |
OLD | NEW |