| 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 net { |
| 21 class URLFetcher; |
| 22 } |
| 23 |
| 20 namespace syncer { | 24 namespace syncer { |
| 21 namespace { | 25 namespace { |
| 22 | 26 |
| 23 using base::TimeDelta; | 27 using base::TimeDelta; |
| 24 | 28 |
| 25 class BlockingHttpPost : public HttpPostProviderInterface { | 29 class BlockingHttpPost : public HttpPostProviderInterface { |
| 26 public: | 30 public: |
| 27 BlockingHttpPost() : wait_for_abort_(false, false) {} | 31 BlockingHttpPost() : wait_for_abort_(false, false) {} |
| 28 ~BlockingHttpPost() override {} | 32 ~BlockingHttpPost() override {} |
| 29 | 33 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 44 return std::string(); | 48 return std::string(); |
| 45 } | 49 } |
| 46 void Abort() override { wait_for_abort_.Signal(); } | 50 void Abort() override { wait_for_abort_.Signal(); } |
| 47 private: | 51 private: |
| 48 base::WaitableEvent wait_for_abort_; | 52 base::WaitableEvent wait_for_abort_; |
| 49 }; | 53 }; |
| 50 | 54 |
| 51 class BlockingHttpPostFactory : public HttpPostProviderFactory { | 55 class BlockingHttpPostFactory : public HttpPostProviderFactory { |
| 52 public: | 56 public: |
| 53 ~BlockingHttpPostFactory() override {} | 57 ~BlockingHttpPostFactory() override {} |
| 54 void Init(const std::string& user_agent) override {} | 58 void Init(const std::string& user_agent, |
| 59 base::Callback<void(net::URLFetcher*)> bind_to_tracker_callback) |
| 60 override {} |
| 55 HttpPostProviderInterface* Create() override { | 61 HttpPostProviderInterface* Create() override { |
| 56 return new BlockingHttpPost(); | 62 return new BlockingHttpPost(); |
| 57 } | 63 } |
| 58 void Destroy(HttpPostProviderInterface* http) override { | 64 void Destroy(HttpPostProviderInterface* http) override { |
| 59 delete static_cast<BlockingHttpPost*>(http); | 65 delete static_cast<BlockingHttpPost*>(http); |
| 60 } | 66 } |
| 61 }; | 67 }; |
| 62 | 68 |
| 63 } // namespace | 69 } // namespace |
| 64 | 70 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 bool result = server.PostBufferToPath( | 124 bool result = server.PostBufferToPath( |
| 119 ¶ms, "/testpath", "testauth", &watcher); | 125 ¶ms, "/testpath", "testauth", &watcher); |
| 120 | 126 |
| 121 EXPECT_FALSE(result); | 127 EXPECT_FALSE(result); |
| 122 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE, | 128 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE, |
| 123 params.response.server_status); | 129 params.response.server_status); |
| 124 abort_thread.Stop(); | 130 abort_thread.Stop(); |
| 125 } | 131 } |
| 126 | 132 |
| 127 } // namespace syncer | 133 } // namespace syncer |
| OLD | NEW |