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_
11 #include "base/message_loop/message_loop.h"
17 // The data associated with an account session.
18 struct AccountSession
{
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
{
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
);
56 GURL
CreateGURLWithPath(const string
& path
);
57 base::MessageLoopForIO io_loop_
;
59 const string account_space_
;
60 vector
<string
> usernames_
;
63 #endif // SYNC_TEST_ACCOUNTS_CLIENT_TEST_ACCOUNTS_CLIENT_H_