Chromium Code Reviews| Index: chrome/browser/policy/device_management_backend_impl.h |
| diff --git a/chrome/browser/policy/device_management_backend_impl.h b/chrome/browser/policy/device_management_backend_impl.h |
| index 648ca5512df2d02d8efc254d2bd1f0fa947929e6..c2eabaec10d3a04337291e3726a1e4c583673412 100644 |
| --- a/chrome/browser/policy/device_management_backend_impl.h |
| +++ b/chrome/browser/policy/device_management_backend_impl.h |
| @@ -13,42 +13,45 @@ |
| #include "chrome/common/net/url_fetcher.h" |
| #include "googleurl/src/gurl.h" |
| +class Profile; |
| class URLRequestContextGetter; |
| namespace policy { |
| -class ResponseHandler; |
| -class URLQueryParameters; |
| +class DeviceManagementJob; |
| // Device management backend implementation. This implementation makes HTTP |
| // requests to the policy server through the net layer. |
| -class DeviceManagementBackendImpl : public DeviceManagementBackend, |
| - public URLFetcher::Delegate { |
| +class DeviceManagementBackendImpl : public URLFetcher::Delegate { |
| public: |
| - explicit DeviceManagementBackendImpl(const std::string& server_url); |
| + // Construct a new device management backend. Client code should not call |
| + // this, it's only public so tests can access it. |
|
markusheintz_
2010/11/18 12:40:36
If the constructor should be private, wouldn't it
Mattias Nissler (ping if slow)
2010/11/19 17:21:53
doesn't apply any longer.
|
| + DeviceManagementBackendImpl(const std::string& server_url, |
| + URLRequestContextGetter* request_context_getter); |
|
danno
2010/11/16 22:02:56
I don't know if it would be cleaner/better, but yo
Mattias Nissler (ping if slow)
2010/11/19 17:21:53
doesn't apply any longer.
|
| virtual ~DeviceManagementBackendImpl(); |
| - // GoogleAppsPolicyService overrides: |
| - virtual void ProcessRegisterRequest( |
| - const std::string& auth_token, |
| - const std::string& device_id, |
| - const em::DeviceRegisterRequest& request, |
| - DeviceRegisterResponseDelegate* response_delegate); |
| - virtual void ProcessUnregisterRequest( |
| - const std::string& device_management_token, |
| - const em::DeviceUnregisterRequest& request, |
| - DeviceUnregisterResponseDelegate* response_delegate); |
| - virtual void ProcessPolicyRequest( |
| - const std::string& device_management_token, |
| - const em::DevicePolicyRequest& request, |
| - DevicePolicyResponseDelegate* response_delegate); |
| + // Constructs a device management backend for use by client code. |
| + static DeviceManagementBackend* Get(); |
|
danno
2010/11/16 22:02:56
I am unsure about the name. I get the whole multi
Mattias Nissler (ping if slow)
2010/11/19 17:21:53
Done.
|
| + |
| + // Initialize the backend. |
| + static DeviceManagementBackendImpl* Initialize(Profile* profile); |
| // Get the agent string (used for HTTP user agent and as agent passed to the |
| // server). |
| static std::string GetAgentString(); |
| private: |
| - typedef std::map<const URLFetcher*, ResponseHandler*> ResponseHandlerMap; |
| + typedef std::map<const URLFetcher*, DeviceManagementJob*> JobFetcherMap; |
| + |
| + friend class DeviceManagementBackendProxy; |
| + |
| + // Starts the given job. Caller must make sure the job pointer stays valid |
| + // until the job completes or CancelJob() gets called. |
| + void StartJob(DeviceManagementJob* job); |
| + |
| + // Cancels a job. The job will be removed and won't receive a completion |
| + // callback. |
| + void CancelJob(DeviceManagementJob* job); |
| // URLFetcher::Delegate override. |
| virtual void OnURLFetchComplete(const URLFetcher* source, |
| @@ -58,14 +61,8 @@ class DeviceManagementBackendImpl : public DeviceManagementBackend, |
| const ResponseCookies& cookies, |
| const std::string& data); |
| - // Create a URLFetcher for a given request message and response handler. |
| - void CreateFetcher(const em::DeviceManagementRequest& request, |
| - ResponseHandler* handler, |
| - const std::string& query_params, |
| - const std::string& extra_headers); |
| - |
| - // Fill in the common query parameters. |
| - void PutCommonQueryParameters(URLQueryParameters* params); |
| + // The static device management backend instance. |
| + static DeviceManagementBackendImpl* instance_; |
| // Server at which to contact the service. |
| const std::string server_url_; |
| @@ -73,8 +70,8 @@ class DeviceManagementBackendImpl : public DeviceManagementBackend, |
| // The request context we use. |
| scoped_refptr<URLRequestContextGetter> request_context_getter_; |
| - // Keeps track of all in-flight requests an their response handlers. |
| - ResponseHandlerMap response_handlers_; |
| + // The jobs we currently have in flight. |
| + JobFetcherMap pending_jobs_; |
| DISALLOW_COPY_AND_ASSIGN(DeviceManagementBackendImpl); |
| }; |