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

Side by Side Diff: chrome/browser/extensions/api/push_messaging/sync_setup_helper.cc

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/push_messaging/sync_setup_helper.h" 5 #include "chrome/browser/extensions/api/push_messaging/sync_setup_helper.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // changes have propagated between the clients. 43 // changes have propagated between the clients.
44 // This could take several seconds. 44 // This could take several seconds.
45 AwaitQuiescence(); 45 AwaitQuiescence();
46 return true; 46 return true;
47 } 47 }
48 48
49 // Read the sync signin credentials from a file on the machine. 49 // Read the sync signin credentials from a file on the machine.
50 bool SyncSetupHelper::ReadPasswordFile(const base::FilePath& password_file) { 50 bool SyncSetupHelper::ReadPasswordFile(const base::FilePath& password_file) {
51 // TODO(dcheng): Convert format of config file to JSON. 51 // TODO(dcheng): Convert format of config file to JSON.
52 std::string file_contents; 52 std::string file_contents;
53 bool success = file_util::ReadFileToString(password_file, &file_contents); 53 bool success = base::ReadFileToString(password_file, &file_contents);
54 EXPECT_TRUE(success) 54 EXPECT_TRUE(success)
55 << "Password file \"" 55 << "Password file \""
56 << password_file.value() << "\" does not exist."; 56 << password_file.value() << "\" does not exist.";
57 if (!success) 57 if (!success)
58 return false; 58 return false;
59 59
60 std::vector<std::string> tokens; 60 std::vector<std::string> tokens;
61 std::string delimiters = "\r\n"; 61 std::string delimiters = "\r\n";
62 Tokenize(file_contents, delimiters, &tokens); 62 Tokenize(file_contents, delimiters, &tokens);
63 EXPECT_EQ(5U, tokens.size()) << "Password file \"" 63 EXPECT_EQ(5U, tokens.size()) << "Password file \""
64 << password_file.value() 64 << password_file.value()
65 << "\" must contain exactly five lines of text."; 65 << "\" must contain exactly five lines of text.";
66 if (5U != tokens.size()) 66 if (5U != tokens.size())
67 return false; 67 return false;
68 username_ = tokens[0]; 68 username_ = tokens[0];
69 password_ = tokens[1]; 69 password_ = tokens[1];
70 client_id_ = tokens[2]; 70 client_id_ = tokens[2];
71 client_secret_ = tokens[3]; 71 client_secret_ = tokens[3];
72 refresh_token_ = tokens[4]; 72 refresh_token_ = tokens[4];
73 return true; 73 return true;
74 } 74 }
75 75
76 bool SyncSetupHelper::AwaitQuiescence() { 76 bool SyncSetupHelper::AwaitQuiescence() {
77 std::vector<ProfileSyncServiceHarness*> clients; 77 std::vector<ProfileSyncServiceHarness*> clients;
78 clients.push_back(client_.get()); 78 clients.push_back(client_.get());
79 return ProfileSyncServiceHarness::AwaitQuiescence(clients); 79 return ProfileSyncServiceHarness::AwaitQuiescence(clients);
80 } 80 }
81 81
82 } // namespace extensions 82 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698