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

Side by Side Diff: chrome/browser/chromeos/policy/status_uploader.h

Issue 2314813002: Refactored DeviceStatusCollector to enable truely asynchronous status queries (Closed)
Patch Set: Initialize *status_ in the C++11'y way Created 4 years, 2 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) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 CHROME_BROWSER_CHROMEOS_POLICY_STATUS_UPLOADER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_STATUS_UPLOADER_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_STATUS_UPLOADER_H_ 6 #define CHROME_BROWSER_CHROMEOS_POLICY_STATUS_UPLOADER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // Callback invoked via a delay to upload device status. 104 // Callback invoked via a delay to upload device status.
105 base::CancelableClosure upload_callback_; 105 base::CancelableClosure upload_callback_;
106 106
107 // True if there has been any captured media in this session. 107 // True if there has been any captured media in this session.
108 bool has_captured_media_; 108 bool has_captured_media_;
109 109
110 // Note: This should remain the last member so it'll be destroyed and 110 // Note: This should remain the last member so it'll be destroyed and
111 // invalidate the weak pointers before any other members are destroyed. 111 // invalidate the weak pointers before any other members are destroyed.
112 base::WeakPtrFactory<StatusUploader> weak_factory_; 112 base::WeakPtrFactory<StatusUploader> weak_factory_;
113 113
114 // Small helper class for state tracking. Necessary because
115 // DeviceStatusCollector has two independent async calls for getting device
116 // and session status, but we need BOTH results before we can upload data.
117 class StatusGetter : public base::RefCountedThreadSafe<StatusGetter> {
118 public:
119 explicit StatusGetter(const base::WeakPtr<StatusUploader>& uploader);
120
121 void OnDeviceStatusReceived(
122 std::unique_ptr<enterprise_management::DeviceStatusReportRequest>
123 device_status);
124 void OnSessionStatusReceived(
125 std::unique_ptr<enterprise_management::SessionStatusReportRequest>
126 session_status);
127
128 private:
129 friend class RefCountedThreadSafe<StatusGetter>;
130 ~StatusGetter();
131
132 void CheckDone();
133
134 std::unique_ptr<enterprise_management::DeviceStatusReportRequest>
135 device_status_;
136 std::unique_ptr<enterprise_management::SessionStatusReportRequest>
137 session_status_;
138
139 base::WeakPtr<StatusUploader> uploader_;
140
141 bool device_status_response_received_;
142 bool session_status_response_received_;
143 };
144
145 DISALLOW_COPY_AND_ASSIGN(StatusUploader); 114 DISALLOW_COPY_AND_ASSIGN(StatusUploader);
146 }; 115 };
147 116
148 } // namespace policy 117 } // namespace policy
149 118
150 #endif // CHROME_BROWSER_CHROMEOS_POLICY_STATUS_UPLOADER_H_ 119 #endif // CHROME_BROWSER_CHROMEOS_POLICY_STATUS_UPLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698