Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: sync/test/fake_server/fake_server_http_post_provider.h

Issue 234113002: Use FakeServer-based invalidations for Sync tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_POST_PROVIDER_H_ 5 #ifndef SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_POST_PROVIDER_H_
6 #define SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_POST_PROVIDER_H_ 6 #define SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_POST_PROVIDER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/synchronization/waitable_event.h"
11 #include "sync/internal_api/public/http_post_provider_factory.h" 12 #include "sync/internal_api/public/http_post_provider_factory.h"
12 #include "sync/internal_api/public/http_post_provider_interface.h" 13 #include "sync/internal_api/public/http_post_provider_interface.h"
13 14
14 namespace fake_server { 15 namespace fake_server {
15 16
16 class FakeServer; 17 class FakeServer;
17 18
18 class FakeServerHttpPostProvider 19 class FakeServerHttpPostProvider
19 : public syncer::HttpPostProviderInterface, 20 : public syncer::HttpPostProviderInterface,
20 public base::RefCountedThreadSafe<FakeServerHttpPostProvider> { 21 public base::RefCountedThreadSafe<FakeServerHttpPostProvider> {
(...skipping 11 matching lines...) Expand all
32 virtual int GetResponseContentLength() const OVERRIDE; 33 virtual int GetResponseContentLength() const OVERRIDE;
33 virtual const char* GetResponseContent() const OVERRIDE; 34 virtual const char* GetResponseContent() const OVERRIDE;
34 virtual const std::string GetResponseHeaderValue( 35 virtual const std::string GetResponseHeaderValue(
35 const std::string& name) const OVERRIDE; 36 const std::string& name) const OVERRIDE;
36 37
37 protected: 38 protected:
38 friend class base::RefCountedThreadSafe<FakeServerHttpPostProvider>; 39 friend class base::RefCountedThreadSafe<FakeServerHttpPostProvider>;
39 virtual ~FakeServerHttpPostProvider(); 40 virtual ~FakeServerHttpPostProvider();
40 41
41 private: 42 private:
43 void OnPostComplete();
44
42 FakeServer* const fake_server_; 45 FakeServer* const fake_server_;
43 std::string response_; 46 std::string response_;
44 std::string request_url_; 47 std::string request_url_;
45 int request_port_; 48 int request_port_;
46 std::string request_content_; 49 std::string request_content_;
47 std::string request_content_type_; 50 std::string request_content_type_;
48 std::string extra_request_headers_; 51 std::string extra_request_headers_;
52 base::WaitableEvent post_complete_;
49 53
50 DISALLOW_COPY_AND_ASSIGN(FakeServerHttpPostProvider); 54 DISALLOW_COPY_AND_ASSIGN(FakeServerHttpPostProvider);
51 }; 55 };
52 56
53 class FakeServerHttpPostProviderFactory 57 class FakeServerHttpPostProviderFactory
54 : public syncer::HttpPostProviderFactory { 58 : public syncer::HttpPostProviderFactory {
55 public: 59 public:
56 explicit FakeServerHttpPostProviderFactory(FakeServer* fake_server); 60 explicit FakeServerHttpPostProviderFactory(FakeServer* fake_server);
57 virtual ~FakeServerHttpPostProviderFactory(); 61 virtual ~FakeServerHttpPostProviderFactory();
58 62
59 // HttpPostProviderFactory: 63 // HttpPostProviderFactory:
60 virtual void Init(const std::string& user_agent) OVERRIDE; 64 virtual void Init(const std::string& user_agent) OVERRIDE;
61 virtual syncer::HttpPostProviderInterface* Create() OVERRIDE; 65 virtual syncer::HttpPostProviderInterface* Create() OVERRIDE;
62 virtual void Destroy(syncer::HttpPostProviderInterface* http) OVERRIDE; 66 virtual void Destroy(syncer::HttpPostProviderInterface* http) OVERRIDE;
63 67
64 private: 68 private:
65 FakeServer* const fake_server_; 69 FakeServer* const fake_server_;
66 70
67 DISALLOW_COPY_AND_ASSIGN(FakeServerHttpPostProviderFactory); 71 DISALLOW_COPY_AND_ASSIGN(FakeServerHttpPostProviderFactory);
68 }; 72 };
69 73
70 } // namespace fake_server 74 } // namespace fake_server
71 75
72 #endif // SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_POST_PROVIDER_H_ 76 #endif // SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_POST_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698