| Index: chrome/browser/supervised_user/experimental/supervised_user_report_url_apiary.h
|
| diff --git a/chrome/browser/supervised_user/experimental/supervised_user_report_url_apiary.h b/chrome/browser/supervised_user/experimental/supervised_user_report_url_apiary.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8e529370b66953830cc4d1140df1e22bfc6b74ef
|
| --- /dev/null
|
| +++ b/chrome/browser/supervised_user/experimental/supervised_user_report_url_apiary.h
|
| @@ -0,0 +1,77 @@
|
| +// Copyright 2014 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 CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_REPORT_URL_H_
|
| +#define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_REPORT_URL_H_
|
| +
|
| +#include <stddef.h>
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "chrome/browser/supervised_user/report_url_request_creator.h"
|
| +#include "google_apis/gaia/oauth2_token_service.h"
|
| +#include "net/url_request/url_fetcher_delegate.h"
|
| +#include "base/callback_forward.h"
|
| +#include "base/containers/mru_cache.h"
|
| +#include "base/macros.h"
|
| +#include "url/gurl.h"
|
| +
|
| +class GURL;
|
| +class Profile;
|
| +
|
| +namespace net {
|
| + class URLFetcher;
|
| + class URLRequestContextGetter;
|
| +}
|
| +
|
| +class SupervisedUserReportURLApiary : public OAuth2TokenService::Consumer,
|
| + public net::URLFetcherDelegate,
|
| + public ReportUrlRequestCreator {
|
| +
|
| + public:
|
| + SupervisedUserReportURLApiary(
|
| + OAuth2TokenService* oauth2_token_service,
|
| + const std::string& account_id,
|
| + net::URLRequestContextGetter* context);
|
| + ~SupervisedUserReportURLApiary() override;
|
| +
|
| + static scoped_ptr<ReportUrlRequestCreator> CreateWithProfile(
|
| + Profile* profile);
|
| +
|
| + // ReportUrlRequestCreator implementation
|
| + void CreateReportUrlRequest(const GURL& url,
|
| + const SuccessCallback& callback) override;
|
| +
|
| + void set_url_fetcher_id_for_testing(int id) { url_fetcher_id_ = id; }
|
| +
|
| + private:
|
| + struct Request;
|
| + using RequestIterator = std::vector<scoped_ptr<Request>>::iterator;
|
| +
|
| + // OAuth2TokenService::Consumer implementation:
|
| + void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
|
| + const std::string& access_token,
|
| + const base::Time& expiration_time) override;
|
| + void OnGetTokenFailure(const OAuth2TokenService::Request* request,
|
| + const GoogleServiceAuthError& error) override;
|
| +
|
| + // net::URLFetcherDelegate implementation.
|
| + void OnURLFetchComplete(const net::URLFetcher* source) override;
|
| +
|
| + // Requests an access token, which is the first thing we need. This is where
|
| + // we restart when the returned access token has expired.
|
| + void StartFetching(Request* request);
|
| +
|
| + void DispatchResult(RequestIterator it, bool success);
|
| +
|
| + OAuth2TokenService* oauth2_token_service_;
|
| + std::string account_id_;
|
| + net::URLRequestContextGetter* context_;
|
| + int url_fetcher_id_;
|
| +
|
| + std::vector<scoped_ptr<Request>> requests_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(SupervisedUserReportURLApiary);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_REPORT_URL_H_
|
|
|