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

Unified Diff: sync/test/fake_server/fake_server_http_post_provider.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: sync/test/fake_server/fake_server_http_post_provider.cc
diff --git a/sync/test/fake_server/fake_server_http_post_provider.cc b/sync/test/fake_server/fake_server_http_post_provider.cc
deleted file mode 100644
index 55666794deac507d08ee6f6efedee3de882ec905..0000000000000000000000000000000000000000
--- a/sync/test/fake_server/fake_server_http_post_provider.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "sync/test/fake_server/fake_server_http_post_provider.h"
-
-#include <string>
-
-#include "base/bind.h"
-#include "base/location.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
-#include "base/sequenced_task_runner.h"
-#include "base/synchronization/waitable_event.h"
-#include "sync/test/fake_server/fake_server.h"
-
-using syncer::HttpPostProviderInterface;
-
-namespace fake_server {
-
-FakeServerHttpPostProviderFactory::FakeServerHttpPostProviderFactory(
- const base::WeakPtr<FakeServer>& fake_server,
- scoped_refptr<base::SequencedTaskRunner> fake_server_task_runner)
- : fake_server_(fake_server),
- fake_server_task_runner_(fake_server_task_runner) { }
-
-FakeServerHttpPostProviderFactory::~FakeServerHttpPostProviderFactory() { }
-
-void FakeServerHttpPostProviderFactory::Init(
- const std::string& user_agent,
- const syncer::BindToTrackerCallback& bind_to_tracker_callback) {}
-
-HttpPostProviderInterface* FakeServerHttpPostProviderFactory::Create() {
- FakeServerHttpPostProvider* http =
- new FakeServerHttpPostProvider(fake_server_, fake_server_task_runner_);
- http->AddRef();
- return http;
-}
-
-void FakeServerHttpPostProviderFactory::Destroy(
- HttpPostProviderInterface* http) {
- static_cast<FakeServerHttpPostProvider*>(http)->Release();
-}
-
-FakeServerHttpPostProvider::FakeServerHttpPostProvider(
- const base::WeakPtr<FakeServer>& fake_server,
- scoped_refptr<base::SequencedTaskRunner> fake_server_task_runner)
- : fake_server_(fake_server),
- fake_server_task_runner_(fake_server_task_runner) { }
-
-FakeServerHttpPostProvider::~FakeServerHttpPostProvider() { }
-
-void FakeServerHttpPostProvider::SetExtraRequestHeaders(const char* headers) {
- // TODO(pvalenzuela): Add assertions on this value.
- extra_request_headers_.assign(headers);
-}
-
-void FakeServerHttpPostProvider::SetURL(const char* url, int port) {
- // TODO(pvalenzuela): Add assertions on these values.
- request_url_.assign(url);
- request_port_ = port;
-}
-
-void FakeServerHttpPostProvider::SetPostPayload(const char* content_type,
- int content_length,
- const char* content) {
- request_content_type_.assign(content_type);
- request_content_.assign(content, content_length);
-}
-
-bool FakeServerHttpPostProvider::MakeSynchronousPost(int* error_code,
- int* response_code) {
- // It is assumed that a POST is being made to /command.
- int post_error_code = -1;
- int post_response_code = -1;
- std::string post_response;
-
- base::WaitableEvent post_complete(
- base::WaitableEvent::ResetPolicy::AUTOMATIC,
- base::WaitableEvent::InitialState::NOT_SIGNALED);
- base::Closure signal_closure = base::Bind(&base::WaitableEvent::Signal,
- base::Unretained(&post_complete));
-
- bool result = fake_server_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&FakeServer::HandleCommand,
- fake_server_,
- base::ConstRef(request_content_),
- base::ConstRef(signal_closure),
- &post_error_code,
- &post_response_code,
- &post_response));
-
- if (!result)
- return false;
-
- post_complete.Wait();
- post_error_code_ = post_error_code;
- post_response_code_ = post_response_code;
- response_ = post_response;
-
- *error_code = post_error_code_;
- *response_code = post_response_code_;
- return *error_code == 0;
-}
-
-int FakeServerHttpPostProvider::GetResponseContentLength() const {
- return response_.length();
-}
-
-const char* FakeServerHttpPostProvider::GetResponseContent() const {
- return response_.c_str();
-}
-
-const std::string FakeServerHttpPostProvider::GetResponseHeaderValue(
- const std::string& name) const {
- return std::string();
-}
-
-void FakeServerHttpPostProvider::Abort() {
-}
-
-} // namespace fake_server
« no previous file with comments | « sync/test/fake_server/fake_server_http_post_provider.h ('k') | sync/test/fake_server/fake_server_network_resources.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698