OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_POST_PROVIDER_H_ |
| 6 #define SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_POST_PROVIDER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "sync/internal_api/public/http_post_provider_factory.h" |
| 12 #include "sync/internal_api/public/http_post_provider_interface.h" |
| 13 |
| 14 namespace syncer { |
| 15 |
| 16 class FakeServer; |
| 17 |
| 18 class FakeServerHttpPostProvider |
| 19 : public HttpPostProviderInterface, |
| 20 public base::RefCountedThreadSafe<FakeServerHttpPostProvider> { |
| 21 public: |
| 22 FakeServerHttpPostProvider(FakeServer* fake_server); |
| 23 |
| 24 // HttpPostProviderInterface implementation. |
| 25 virtual void SetExtraRequestHeaders(const char* headers) OVERRIDE; |
| 26 virtual void SetURL(const char* url, int port) OVERRIDE; |
| 27 virtual void SetPostPayload(const char* content_type, int content_length, |
| 28 const char* content) OVERRIDE; |
| 29 virtual bool MakeSynchronousPost(int* error_code, |
| 30 int* response_code) OVERRIDE; |
| 31 virtual void Abort() OVERRIDE; |
| 32 virtual int GetResponseContentLength() const OVERRIDE; |
| 33 virtual const char* GetResponseContent() const OVERRIDE; |
| 34 virtual const std::string GetResponseHeaderValue( |
| 35 const std::string& name) const OVERRIDE; |
| 36 |
| 37 protected: |
| 38 friend class base::RefCountedThreadSafe<FakeServerHttpPostProvider>; |
| 39 virtual ~FakeServerHttpPostProvider(); |
| 40 |
| 41 private: |
| 42 FakeServer* const fake_server_; |
| 43 std::string response_; |
| 44 std::string request_url_; |
| 45 int request_port_; |
| 46 std::string request_content_; |
| 47 std::string request_content_type_; |
| 48 std::string extra_request_headers_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(FakeServerHttpPostProvider); |
| 51 }; |
| 52 |
| 53 class FakeServerHttpPostProviderFactory : public HttpPostProviderFactory { |
| 54 public: |
| 55 FakeServerHttpPostProviderFactory(FakeServer* fake_server); |
| 56 virtual ~FakeServerHttpPostProviderFactory(); |
| 57 |
| 58 // HttpPostProviderFactory: |
| 59 virtual void Init(const std::string& user_agent) OVERRIDE; |
| 60 virtual HttpPostProviderInterface* Create() OVERRIDE; |
| 61 virtual void Destroy(HttpPostProviderInterface* http) OVERRIDE; |
| 62 |
| 63 private: |
| 64 FakeServer* const fake_server_; |
| 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(FakeServerHttpPostProviderFactory); |
| 67 }; |
| 68 |
| 69 } // namespace syncer |
| 70 |
| 71 #endif // SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_POST_PROVIDER_H_ |
OLD | NEW |