Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: components/policy/core/common/cloud/device_management_service.h

Issue 1928013004: Add delayed retry to DeviceManagementService requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit: punctuation Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_DEVICE_MANAGEMENT_SERVICE_H_ 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_DEVICE_MANAGEMENT_SERVICE_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_DEVICE_MANAGEMENT_SERVICE_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_DEVICE_MANAGEMENT_SERVICE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
21 #include "base/strings/string_split.h" 21 #include "base/strings/string_split.h"
22 #include "base/threading/thread_checker.h"
22 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 23 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
23 #include "components/policy/policy_export.h" 24 #include "components/policy/policy_export.h"
24 #include "net/url_request/url_fetcher_delegate.h" 25 #include "net/url_request/url_fetcher_delegate.h"
25 #include "policy/proto/device_management_backend.pb.h" 26 #include "policy/proto/device_management_backend.pb.h"
26 27
27 28
28 namespace net { 29 namespace net {
29 class URLRequestContextGetter; 30 class URLRequestContextGetter;
30 } 31 }
31 32
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 149
149 // Schedules a task to run |Initialize| after |delay_milliseconds| had passed. 150 // Schedules a task to run |Initialize| after |delay_milliseconds| had passed.
150 void ScheduleInitialization(int64_t delay_milliseconds); 151 void ScheduleInitialization(int64_t delay_milliseconds);
151 152
152 // Makes the service stop all requests. 153 // Makes the service stop all requests.
153 void Shutdown(); 154 void Shutdown();
154 155
155 // Gets the URL that the DMServer requests are sent to. 156 // Gets the URL that the DMServer requests are sent to.
156 std::string GetServerUrl(); 157 std::string GetServerUrl();
157 158
159 // Sets the retry delay to a shorter time to prevent browser tests from
160 // timing out.
161 static void SetRetryDelayForTesting(long retryDelayMs);
162
158 private: 163 private:
159 typedef std::map<const net::URLFetcher*, 164 typedef std::map<const net::URLFetcher*,
160 DeviceManagementRequestJobImpl*> JobFetcherMap; 165 DeviceManagementRequestJobImpl*> JobFetcherMap;
161 typedef std::deque<DeviceManagementRequestJobImpl*> JobQueue; 166 typedef std::deque<DeviceManagementRequestJobImpl*> JobQueue;
162 167
163 friend class DeviceManagementRequestJobImpl; 168 friend class DeviceManagementRequestJobImpl;
164 169
165 // net::URLFetcherDelegate override. 170 // net::URLFetcherDelegate override.
166 void OnURLFetchComplete(const net::URLFetcher* source) override; 171 void OnURLFetchComplete(const net::URLFetcher* source) override;
167 172
(...skipping 18 matching lines...) Expand all
186 // The jobs we currently have in flight. 191 // The jobs we currently have in flight.
187 JobFetcherMap pending_jobs_; 192 JobFetcherMap pending_jobs_;
188 193
189 // Jobs that are registered, but not started yet. 194 // Jobs that are registered, but not started yet.
190 JobQueue queued_jobs_; 195 JobQueue queued_jobs_;
191 196
192 // If this service is initialized, incoming requests get fired instantly. 197 // If this service is initialized, incoming requests get fired instantly.
193 // If it is not initialized, incoming requests are queued. 198 // If it is not initialized, incoming requests are queued.
194 bool initialized_; 199 bool initialized_;
195 200
196 // Used to create tasks to run |Initialize| delayed on the UI thread. 201 // TaskRunner used to schedule retry attempts.
202 const scoped_refptr<base::SequencedTaskRunner> task_runner_;
203
204 base::ThreadChecker thread_checker_;
205
206 // Used to create tasks which run delayed on the UI thread.
197 base::WeakPtrFactory<DeviceManagementService> weak_ptr_factory_; 207 base::WeakPtrFactory<DeviceManagementService> weak_ptr_factory_;
198 208
199 DISALLOW_COPY_AND_ASSIGN(DeviceManagementService); 209 DISALLOW_COPY_AND_ASSIGN(DeviceManagementService);
200 }; 210 };
201 211
202 } // namespace policy 212 } // namespace policy
203 213
204 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_DEVICE_MANAGEMENT_SERVICE_H_ 214 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_DEVICE_MANAGEMENT_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698