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

Side by Side Diff: sync/test/fake_server/run_sync_fake_server.cc

Issue 264773007: Remove Sync FakeServer standalone executable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « sync/test/fake_server/fake_sync_server_http_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <iostream>
6
7 #include "base/at_exit.h"
8 #include "base/bind.h"
9 #include "base/command_line.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/message_loop/message_loop_proxy.h"
12 #include "base/strings/string_number_conversions.h"
13 #include "sync/test/fake_server/fake_sync_server_http_handler.h"
14
15 const char kPortNumberSwitch[] = "port";
16
17 // This runs a FakeSyncServerHttpHandler as a command-line app.
18 int main(int argc, char* argv[]) {
19 using fake_server::FakeSyncServerHttpHandler;
20
21 CommandLine::Init(argc, argv);
22 CommandLine* command_line = CommandLine::ForCurrentProcess();
23 logging::LoggingSettings settings;
24 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
25 logging::InitLogging(settings);
26
27 FakeSyncServerHttpHandler* server;
28
29 // Check if a port was specified on the command line
30 if (command_line->HasSwitch(kPortNumberSwitch)) {
31 std::string requested_port =
32 command_line->GetSwitchValueASCII(kPortNumberSwitch);
33 int port;
34 if (!base::StringToInt(requested_port, &port)) {
35 LOG(ERROR) << "Invalid --" << kPortNumberSwitch << " specified: \""
36 << requested_port << "\"";
37 return -1;
38 }
39
40 server = new FakeSyncServerHttpHandler(port);
41 } else {
42 LOG(INFO) << "Selecting an avilable port. Pass --" << kPortNumberSwitch
43 << "=<port number> to specify your own.";
44 server = new FakeSyncServerHttpHandler();
45 }
46
47 base::WeakPtrFactory<FakeSyncServerHttpHandler> server_ptr_factory(server);
48
49 // An HttpServer must be run on a IO MessageLoop.
50 base::AtExitManager exit_manager; // Debug builds demand that ExitManager
51 // be initialized before MessageLoop.
52 base::MessageLoop message_loop(base::MessageLoop::TYPE_IO);
53 bool posted = message_loop.current()->message_loop_proxy()->PostTask(
54 FROM_HERE,
55 base::Bind(&FakeSyncServerHttpHandler::Start,
56 server_ptr_factory.GetWeakPtr()));
57 CHECK(posted) << "Failed to start the HTTP server. PostTask returned false.";
58 message_loop.current()->Run();
59
60 return 0;
61 }
OLDNEW
« no previous file with comments | « sync/test/fake_server/fake_sync_server_http_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698