| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/bit_cast.h" | 8 #include "base/bit_cast.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 new net::TestURLRequestContextGetter(io_thread()->task_runner())); | 378 new net::TestURLRequestContextGetter(io_thread()->task_runner())); |
| 379 scoped_refptr<ShuntedHttpBridge> http_bridge( | 379 scoped_refptr<ShuntedHttpBridge> http_bridge( |
| 380 new ShuntedHttpBridge(ctx_getter.get(), this, true)); | 380 new ShuntedHttpBridge(ctx_getter.get(), this, true)); |
| 381 http_bridge->SetURL("http://www.google.com", 9999); | 381 http_bridge->SetURL("http://www.google.com", 9999); |
| 382 http_bridge->SetPostPayload("text/plain", 2, " "); | 382 http_bridge->SetPostPayload("text/plain", 2, " "); |
| 383 | 383 |
| 384 int os_error = 0; | 384 int os_error = 0; |
| 385 int response_code = 0; | 385 int response_code = 0; |
| 386 | 386 |
| 387 io_thread()->task_runner()->PostTask( | 387 io_thread()->task_runner()->PostTask( |
| 388 FROM_HERE, | 388 FROM_HERE, base::Bind(&MAYBE_SyncHttpBridgeTest::Abort, |
| 389 base::Bind(&MAYBE_SyncHttpBridgeTest::Abort, http_bridge)); | 389 base::RetainedRef(http_bridge))); |
| 390 bool success = http_bridge->MakeSynchronousPost(&os_error, &response_code); | 390 bool success = http_bridge->MakeSynchronousPost(&os_error, &response_code); |
| 391 EXPECT_FALSE(success); | 391 EXPECT_FALSE(success); |
| 392 EXPECT_EQ(net::ERR_ABORTED, os_error); | 392 EXPECT_EQ(net::ERR_ABORTED, os_error); |
| 393 } | 393 } |
| 394 | 394 |
| 395 TEST_F(MAYBE_SyncHttpBridgeTest, AbortLate) { | 395 TEST_F(MAYBE_SyncHttpBridgeTest, AbortLate) { |
| 396 scoped_refptr<net::URLRequestContextGetter> ctx_getter( | 396 scoped_refptr<net::URLRequestContextGetter> ctx_getter( |
| 397 new net::TestURLRequestContextGetter(io_thread()->task_runner())); | 397 new net::TestURLRequestContextGetter(io_thread()->task_runner())); |
| 398 scoped_refptr<ShuntedHttpBridge> http_bridge( | 398 scoped_refptr<ShuntedHttpBridge> http_bridge( |
| 399 new ShuntedHttpBridge(ctx_getter.get(), this, false)); | 399 new ShuntedHttpBridge(ctx_getter.get(), this, false)); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 | 573 |
| 574 // Sync thread: Finally run the posted task, only to find that our | 574 // Sync thread: Finally run the posted task, only to find that our |
| 575 // HttpBridgeFactory has been neutered. Should not crash. | 575 // HttpBridgeFactory has been neutered. Should not crash. |
| 576 factory->Init("TestUserAgent", BindToTrackerCallback()); | 576 factory->Init("TestUserAgent", BindToTrackerCallback()); |
| 577 | 577 |
| 578 // At this point, attempting to use the factory would trigger a crash. Both | 578 // At this point, attempting to use the factory would trigger a crash. Both |
| 579 // this test and the real world code should make sure this never happens. | 579 // this test and the real world code should make sure this never happens. |
| 580 } | 580 } |
| 581 | 581 |
| 582 } // namespace syncer | 582 } // namespace syncer |
| OLD | NEW |