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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // If |never_finishes| is true, the simulated request never actually | 117 // If |never_finishes| is true, the simulated request never actually |
118 // returns. | 118 // returns. |
119 ShuntedHttpBridge(net::URLRequestContextGetter* baseline_context_getter, | 119 ShuntedHttpBridge(net::URLRequestContextGetter* baseline_context_getter, |
120 SyncHttpBridgeTest* test, bool never_finishes) | 120 SyncHttpBridgeTest* test, bool never_finishes) |
121 : HttpBridge( | 121 : HttpBridge( |
122 new HttpBridge::RequestContextGetter( | 122 new HttpBridge::RequestContextGetter( |
123 baseline_context_getter, "user agent"), | 123 baseline_context_getter, "user agent"), |
124 NetworkTimeUpdateCallback()), | 124 NetworkTimeUpdateCallback()), |
125 test_(test), never_finishes_(never_finishes) { } | 125 test_(test), never_finishes_(never_finishes) { } |
126 protected: | 126 protected: |
127 virtual void MakeAsynchronousPost() OVERRIDE { | 127 virtual void MakeAsynchronousPost() override { |
128 ASSERT_TRUE(base::MessageLoop::current() == test_->GetIOThreadLoop()); | 128 ASSERT_TRUE(base::MessageLoop::current() == test_->GetIOThreadLoop()); |
129 if (never_finishes_) | 129 if (never_finishes_) |
130 return; | 130 return; |
131 | 131 |
132 // We don't actually want to make a request for this test, so just callback | 132 // We don't actually want to make a request for this test, so just callback |
133 // as if it completed. | 133 // as if it completed. |
134 test_->GetIOThreadLoop()->PostTask(FROM_HERE, | 134 test_->GetIOThreadLoop()->PostTask(FROM_HERE, |
135 base::Bind(&ShuntedHttpBridge::CallOnURLFetchComplete, this)); | 135 base::Bind(&ShuntedHttpBridge::CallOnURLFetchComplete, this)); |
136 } | 136 } |
137 private: | 137 private: |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |