summaryrefslogtreecommitdiffstats
path: root/cloud_print/gcp20/prototype/command_line_reader.cc
diff options
context:
space:
mode:
authormaksymb@chromium.org <maksymb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-23 15:39:15 +0000
committermaksymb@chromium.org <maksymb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-23 15:39:15 +0000
commita20b019ab8ee1eeba45257d9c8774e88b1a665e4 (patch)
tree8b62906129a1a89134c3a9447026fcdf885da71b /cloud_print/gcp20/prototype/command_line_reader.cc
parent73f6d0a7200a072972d4c8dd774f6f5cd341ff47 (diff)
downloadchromium_src-a20b019ab8ee1eeba45257d9c8774e88b1a665e4.zip
chromium_src-a20b019ab8ee1eeba45257d9c8774e88b1a665e4.tar.gz
chromium_src-a20b019ab8ee1eeba45257d9c8774e88b1a665e4.tar.bz2
XPrivetToken, saving to file, little extend for /privet/info.
Review URL: https://chromiumcodereview.appspot.com/18703004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213129 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cloud_print/gcp20/prototype/command_line_reader.cc')
-rw-r--r--cloud_print/gcp20/prototype/command_line_reader.cc53
1 files changed, 53 insertions, 0 deletions
diff --git a/cloud_print/gcp20/prototype/command_line_reader.cc b/cloud_print/gcp20/prototype/command_line_reader.cc
new file mode 100644
index 0000000..a5474e6
--- /dev/null
+++ b/cloud_print/gcp20/prototype/command_line_reader.cc
@@ -0,0 +1,53 @@
+// Copyright 2013 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 "cloud_print/gcp20/prototype/command_line_reader.h"
+
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+
+namespace {
+
+const uint16 kDefaultHttpPort = 10101;
+const uint32 kDefaultTTL = 60*60;
+
+} // namespace
+
+namespace command_line_reader {
+
+uint16 ReadHttpPort() {
+ uint32 http_port = kDefaultHttpPort;
+
+ std::string http_port_string =
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII("http-port");
+
+ if (!base::StringToUint(http_port_string, &http_port))
+ http_port = kDefaultHttpPort;
+
+ if (http_port > kuint16max) {
+ LOG(ERROR) << "Port " << http_port << " is too large (maximum is " <<
+ kuint16max << "). Using default port: " << kDefaultHttpPort;
+
+ http_port = kDefaultHttpPort;
+ }
+
+ VLOG(1) << "HTTP port for responses: " << http_port;
+ return static_cast<uint16>(http_port);
+}
+
+uint32 ReadTtl() {
+ uint32 ttl = kDefaultTTL;
+
+ if (!base::StringToUint(
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII("ttl"), &ttl)) {
+ ttl = kDefaultTTL;
+ }
+
+ VLOG(1) << "TTL for announcements: " << ttl;
+ return ttl;
+}
+
+} // namespace command_line_reader
+