| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "sync/internal_api/syncapi_server_connection_manager.h" | 5 #include "sync/internal_api/syncapi_server_connection_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| 11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "sync/internal_api/public/base/cancelation_signal.h" | 15 #include "sync/internal_api/public/base/cancelation_signal.h" |
| 16 #include "sync/internal_api/public/http_post_provider_factory.h" | 16 #include "sync/internal_api/public/http_post_provider_factory.h" |
| 17 #include "sync/internal_api/public/http_post_provider_interface.h" | 17 #include "sync/internal_api/public/http_post_provider_interface.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 namespace syncer { | 20 namespace syncer { |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 using base::TimeDelta; | 23 using base::TimeDelta; |
| 24 | 24 |
| 25 class BlockingHttpPost : public HttpPostProviderInterface { | 25 class BlockingHttpPost : public HttpPostProviderInterface { |
| 26 public: | 26 public: |
| 27 BlockingHttpPost() : wait_for_abort_(false, false) {} | 27 BlockingHttpPost() |
| 28 : wait_for_abort_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 29 base::WaitableEvent::InitialState::NOT_SIGNALED) {} |
| 28 ~BlockingHttpPost() override {} | 30 ~BlockingHttpPost() override {} |
| 29 | 31 |
| 30 void SetExtraRequestHeaders(const char* headers) override {} | 32 void SetExtraRequestHeaders(const char* headers) override {} |
| 31 void SetURL(const char* url, int port) override {} | 33 void SetURL(const char* url, int port) override {} |
| 32 void SetPostPayload(const char* content_type, | 34 void SetPostPayload(const char* content_type, |
| 33 int content_length, | 35 int content_length, |
| 34 const char* content) override {} | 36 const char* content) override {} |
| 35 bool MakeSynchronousPost(int* error_code, int* response_code) override { | 37 bool MakeSynchronousPost(int* error_code, int* response_code) override { |
| 36 wait_for_abort_.TimedWait(TestTimeouts::action_max_timeout()); | 38 wait_for_abort_.TimedWait(TestTimeouts::action_max_timeout()); |
| 37 *error_code = net::ERR_ABORTED; | 39 *error_code = net::ERR_ABORTED; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 ServerConnectionManager::PostBufferParams params; | 182 ServerConnectionManager::PostBufferParams params; |
| 181 | 183 |
| 182 bool result = server.PostBufferToPath(¶ms, "/testpath", "testauth"); | 184 bool result = server.PostBufferToPath(¶ms, "/testpath", "testauth"); |
| 183 | 185 |
| 184 EXPECT_FALSE(result); | 186 EXPECT_FALSE(result); |
| 185 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE, | 187 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE, |
| 186 params.response.server_status); | 188 params.response.server_status); |
| 187 } | 189 } |
| 188 | 190 |
| 189 } // namespace syncer | 191 } // namespace syncer |
| OLD | NEW |