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

Side by Side Diff: blimp/engine/app/blimp_engine_config.cc

Issue 1929723002: [Blimp] Adds blimp engine browser test framework and LoadUrl test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "blimp/engine/app/blimp_engine_config.h" 5 #include "blimp/engine/app/blimp_engine_config.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "blimp/engine/app/switches.h" 15 #include "blimp/engine/app/switches.h"
16 16
17 namespace blimp { 17 namespace blimp {
18 namespace engine { 18 namespace engine {
19 19
20 namespace { 20 namespace {
21 // Gets the client token from the file provided by the command line. If a read 21 // Gets the client token from the command line. Either from the token provided,
22 // or from the file provided by the command line. If a file read
22 // does not succeed, or the switch is malformed, an empty string is returned. 23 // does not succeed, or the switch is malformed, an empty string is returned.
23 std::string GetClientToken(const base::CommandLine& cmd_line) { 24 std::string GetClientToken(const base::CommandLine& cmd_line) {
24 std::string file_contents; 25 std::string token;
25 const base::FilePath path = cmd_line.GetSwitchValuePath(kClientTokenPath); 26 if (cmd_line.HasSwitch(kClientToken)) {
26 if (!base::ReadFileToString(path, &file_contents)) { 27 token = cmd_line.GetSwitchValueASCII(kClientToken);
27 LOG(ERROR) << "Could not read client token file at " 28 } else {
28 << (path.empty() ? "(not provided)" : path.AsUTF8Unsafe()); 29 DCHECK(cmd_line.HasSwitch(kClientTokenPath));
30 const base::FilePath path = cmd_line.GetSwitchValuePath(kClientTokenPath);
31 if (!base::ReadFileToString(path, &token)) {
32 LOG(ERROR) << "Could not read client token file at "
33 << (path.empty() ? "(not provided)" : path.AsUTF8Unsafe());
34 }
29 } 35 }
30 return base::CollapseWhitespaceASCII(file_contents, true); 36 return base::CollapseWhitespaceASCII(token, true);
31 } 37 }
32 } // namespace 38 } // namespace
33 39
34 BlimpEngineConfig::~BlimpEngineConfig() {} 40 BlimpEngineConfig::~BlimpEngineConfig() {}
35 41
36 // static 42 // static
37 std::unique_ptr<BlimpEngineConfig> BlimpEngineConfig::Create( 43 std::unique_ptr<BlimpEngineConfig> BlimpEngineConfig::Create(
38 const base::CommandLine& cmd_line) { 44 const base::CommandLine& cmd_line) {
39 const std::string client_token = GetClientToken(cmd_line); 45 const std::string client_token = GetClientToken(cmd_line);
40 if (!client_token.empty()) { 46 if (!client_token.empty()) {
(...skipping 10 matching lines...) Expand all
51 57
52 const std::string& BlimpEngineConfig::client_token() const { 58 const std::string& BlimpEngineConfig::client_token() const {
53 return client_token_; 59 return client_token_;
54 } 60 }
55 61
56 BlimpEngineConfig::BlimpEngineConfig(const std::string& client_token) 62 BlimpEngineConfig::BlimpEngineConfig(const std::string& client_token)
57 : client_token_(client_token) {} 63 : client_token_(client_token) {}
58 64
59 } // namespace engine 65 } // namespace engine
60 } // namespace blimp 66 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698