| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_SYNC_ENGINE_IMPL_LOOPBACK_SERVER_LOOPBACK_SERVER_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_LOOPBACK_SERVER_LOOPBACK_SERVER_H_ |
| 6 #define COMPONENTS_SYNC_ENGINE_IMPL_LOOPBACK_SERVER_LOOPBACK_SERVER_H_ | 6 #define COMPONENTS_SYNC_ENGINE_IMPL_LOOPBACK_SERVER_LOOPBACK_SERVER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "components/sync/base/model_type.h" | 19 #include "components/sync/base/model_type.h" |
| 20 #include "components/sync/engine_impl/loopback_server/loopback_server_entity.h" | 20 #include "components/sync/engine_impl/loopback_server/loopback_server_entity.h" |
| 21 #include "components/sync/engine_impl/net/server_connection_manager.h" | 21 #include "components/sync/engine_impl/net/server_connection_manager.h" |
| 22 #include "components/sync/protocol/loopback_server.pb.h" | 22 #include "components/sync/protocol/loopback_server.pb.h" |
| 23 #include "components/sync/protocol/sync.pb.h" | 23 #include "components/sync/protocol/sync.pb.h" |
| 24 | 24 |
| 25 namespace syncer { | 25 namespace syncer { |
| 26 | 26 |
| 27 // A loopback version of the Sync server used for local profile serialization. | 27 // A loopback version of the Sync server used for local profile serialization. |
| 28 class LoopbackServer { | 28 class LoopbackServer { |
| 29 public: | 29 public: |
| 30 LoopbackServer(const base::FilePath& persistent_file); | 30 explicit LoopbackServer(const base::FilePath& persistent_file); |
| 31 virtual ~LoopbackServer(); | 31 virtual ~LoopbackServer(); |
| 32 | 32 |
| 33 // Handles a /command POST (with the given |request|) to the server. Three | 33 // Handles a /command POST (with the given |request|) to the server. Three |
| 34 // output arguments, |server_status|, |response_code|, and |response|, are | 34 // output arguments, |server_status|, |response_code|, and |response|, are |
| 35 // used to pass data back to the caller. The command has failed if the value | 35 // used to pass data back to the caller. The command has failed if the value |
| 36 // pointed to by |error_code| is nonzero. | 36 // pointed to by |error_code| is nonzero. |
| 37 void HandleCommand(const std::string& request, | 37 void HandleCommand(const std::string& request, |
| 38 HttpResponse::ServerConnectionCode* server_status, | 38 HttpResponse::ServerConnectionCode* server_status, |
| 39 int64_t* response_code, | 39 int64_t* response_code, |
| 40 std::string* response); | 40 std::string* response); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // The file used to store the local sync data. | 126 // The file used to store the local sync data. |
| 127 base::FilePath persistent_file_; | 127 base::FilePath persistent_file_; |
| 128 | 128 |
| 129 // Used to verify that LoopbackServer is only used from one thread. | 129 // Used to verify that LoopbackServer is only used from one thread. |
| 130 base::ThreadChecker thread_checker_; | 130 base::ThreadChecker thread_checker_; |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 } // namespace syncer | 133 } // namespace syncer |
| 134 | 134 |
| 135 #endif // COMPONENTS_SYNC_ENGINE_IMPL_LOOPBACK_SERVER_LOOPBACK_SERVER_H_ | 135 #endif // COMPONENTS_SYNC_ENGINE_IMPL_LOOPBACK_SERVER_LOOPBACK_SERVER_H_ |
| OLD | NEW |