OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/synchronization/waitable_event.h" | 5 #include "base/synchronization/waitable_event.h" |
6 #include "base/threading/thread.h" | 6 #include "base/threading/thread.h" |
7 #include "net/test/spawned_test_server/spawned_test_server.h" | 7 #include "net/test/spawned_test_server/spawned_test_server.h" |
8 #include "net/url_request/test_url_fetcher_factory.h" | 8 #include "net/url_request/test_url_fetcher_factory.h" |
9 #include "net/url_request/url_fetcher_delegate.h" | 9 #include "net/url_request/url_fetcher_delegate.h" |
10 #include "net/url_request/url_request_test_util.h" | 10 #include "net/url_request/url_request_test_util.h" |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 TEST_F(SyncHttpBridgeTest, EarlyAbortFactory) { | 492 TEST_F(SyncHttpBridgeTest, EarlyAbortFactory) { |
493 // In a real scenario, the following would happen on many threads. For | 493 // In a real scenario, the following would happen on many threads. For |
494 // simplicity, this test uses only one thread. | 494 // simplicity, this test uses only one thread. |
495 | 495 |
496 scoped_refptr<net::URLRequestContextGetter> baseline_context_getter( | 496 scoped_refptr<net::URLRequestContextGetter> baseline_context_getter( |
497 new net::TestURLRequestContextGetter(io_thread()->message_loop_proxy())); | 497 new net::TestURLRequestContextGetter(io_thread()->message_loop_proxy())); |
498 CancelationSignal release_request_context_signal; | 498 CancelationSignal release_request_context_signal; |
499 | 499 |
500 // UI Thread: Initialize the HttpBridgeFactory. The next step would be to | 500 // UI Thread: Initialize the HttpBridgeFactory. The next step would be to |
501 // post a task to SBH::Core to have it initialized. | 501 // post a task to SBH::Core to have it initialized. |
502 scoped_ptr<syncer::HttpBridgeFactory> factory(new HttpBridgeFactory( | 502 scoped_ptr<syncer::HttpBridgeFactory> factory( |
503 baseline_context_getter, | 503 new HttpBridgeFactory(baseline_context_getter.get(), |
504 NetworkTimeUpdateCallback(), | 504 NetworkTimeUpdateCallback(), |
505 &release_request_context_signal)); | 505 &release_request_context_signal)); |
506 | 506 |
507 // UI Thread: A very early shutdown request arrives and executes on the UI | 507 // UI Thread: A very early shutdown request arrives and executes on the UI |
508 // thread before the posted sync thread task is run. | 508 // thread before the posted sync thread task is run. |
509 release_request_context_signal.Signal(); | 509 release_request_context_signal.Signal(); |
510 | 510 |
511 // Sync thread: Finally run the posted task, only to find that our | 511 // Sync thread: Finally run the posted task, only to find that our |
512 // HttpBridgeFactory has been neutered. Should not crash. | 512 // HttpBridgeFactory has been neutered. Should not crash. |
513 factory->Init("TestUserAgent"); | 513 factory->Init("TestUserAgent"); |
514 | 514 |
515 // At this point, attempting to use the factory would trigger a crash. Both | 515 // At this point, attempting to use the factory would trigger a crash. Both |
516 // this test and the real world code should make sure this never happens. | 516 // this test and the real world code should make sure this never happens. |
517 }; | 517 }; |
518 | 518 |
519 } // namespace syncer | 519 } // namespace syncer |
OLD | NEW |