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