Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / sync / test / accounts_client / test_accounts_client.h
blob15a582e7229380e430c44d5aa54a7d07554a2501
1 // Copyright 2013 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.
5 #ifndef SYNC_TEST_ACCOUNTS_CLIENT_TEST_ACCOUNTS_CLIENT_H_
6 #define SYNC_TEST_ACCOUNTS_CLIENT_TEST_ACCOUNTS_CLIENT_H_
8 #include <string>
9 #include <vector>
11 #include "base/message_loop/message_loop.h"
12 #include "url/gurl.h"
14 using std::string;
15 using std::vector;
17 // The data associated with an account session.
18 struct AccountSession {
19 AccountSession();
20 ~AccountSession();
22 string username;
23 string account_space;
24 string session_id;
25 string expiration_time;
28 // A test-side client for the Test Accounts service. This service provides
29 // short-term, exclusive access to test accounts for the purpose of testing
30 // against real Chrome Sync servers.
31 class TestAccountsClient {
32 public:
33 // Creates a client associated with the given |server| URL (e.g.,
34 // http://service-runs-here.com), |account_space| (for account segregation),
35 // and |usernames| (the collection of accounts to be chosen from).
36 TestAccountsClient(const string& server,
37 const string& account_space,
38 const vector<string>& usernames);
40 virtual ~TestAccountsClient();
42 // Attempts to claim an account via the Test Accounts service. If
43 // successful, true is returned and the given |session| has its data set.
44 // If an error occurred, then false is returned.
45 bool ClaimAccount(AccountSession* session);
47 // Attempts to release an account via the Test Accounts service. The value
48 // of |session| should be one returned from ClaimAccount(). This function
49 // is best-effort and fails silently.
50 void ReleaseAccount(const AccountSession& session);
52 // Sends an HTTP POST request to the Test Accounts service.
53 virtual bool SendRequest(const GURL& url, string* response);
55 private:
56 GURL CreateGURLWithPath(const string& path);
57 base::MessageLoopForIO io_loop_;
58 const string server_;
59 const string account_space_;
60 vector<string> usernames_;
63 #endif // SYNC_TEST_ACCOUNTS_CLIENT_TEST_ACCOUNTS_CLIENT_H_