Commit bd3da15f authored by Leonardo Padilha's avatar Leonardo Padilha Committed by Commit Bot

Return whether request to schedule immediate status report was successful.

This information will be used to collect metrics on events that trigger status reports. We need to know  whether the call to schedule a report was successful or not.

Bug: 919132
Change-Id: If0be7c5d7d11a686707a1a20a2a6d6ad519a31ba
Reviewed-on: https://chromium-review.googlesource.com/c/1418272Reviewed-by: default avatarBartosz Fabianowski <bartfab@chromium.org>
Commit-Queue: Leonardo Padilha <ldaguilar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626118}
parent 6879cff0
...@@ -72,13 +72,13 @@ StatusUploader::~StatusUploader() { ...@@ -72,13 +72,13 @@ StatusUploader::~StatusUploader() {
MediaCaptureDevicesDispatcher::GetInstance()->RemoveObserver(this); MediaCaptureDevicesDispatcher::GetInstance()->RemoveObserver(this);
} }
void StatusUploader::ScheduleNextStatusUpload(bool immediately) { bool StatusUploader::ScheduleNextStatusUpload(bool immediately) {
// Don't schedule a new status upload if there's a status upload in progress // Don't schedule a new status upload if there's a status upload in progress
// (it will be scheduled once the current one completes). // (it will be scheduled once the current one completes).
if (status_upload_in_progress_) { if (status_upload_in_progress_) {
SYSLOG(INFO) << "In the middle of a status upload, not scheduling the next " SYSLOG(INFO) << "In the middle of a status upload, not scheduling the next "
<< "one until this one finishes."; << "one until this one finishes.";
return; return false;
} }
// Calculate when to fire off the next update (if it should have already // Calculate when to fire off the next update (if it should have already
...@@ -93,6 +93,7 @@ void StatusUploader::ScheduleNextStatusUpload(bool immediately) { ...@@ -93,6 +93,7 @@ void StatusUploader::ScheduleNextStatusUpload(bool immediately) {
upload_callback_.Reset(base::Bind(&StatusUploader::UploadStatus, upload_callback_.Reset(base::Bind(&StatusUploader::UploadStatus,
base::Unretained(this))); base::Unretained(this)));
task_runner_->PostDelayedTask(FROM_HERE, upload_callback_.callback(), delay); task_runner_->PostDelayedTask(FROM_HERE, upload_callback_.callback(), delay);
return true;
} }
void StatusUploader::RefreshUploadFrequency() { void StatusUploader::RefreshUploadFrequency() {
...@@ -172,8 +173,8 @@ void StatusUploader::OnRequestUpdate(int render_process_id, ...@@ -172,8 +173,8 @@ void StatusUploader::OnRequestUpdate(int render_process_id,
} }
} }
void StatusUploader::ScheduleNextStatusUploadImmediately() { bool StatusUploader::ScheduleNextStatusUploadImmediately() {
ScheduleNextStatusUpload(true); return ScheduleNextStatusUpload(true);
} }
void StatusUploader::UploadStatus() { void StatusUploader::UploadStatus() {
......
...@@ -55,7 +55,9 @@ class StatusUploader : public MediaCaptureDevicesDispatcher::Observer { ...@@ -55,7 +55,9 @@ class StatusUploader : public MediaCaptureDevicesDispatcher::Observer {
blink::MediaStreamType stream_type, blink::MediaStreamType stream_type,
const content::MediaRequestState state) override; const content::MediaRequestState state) override;
void ScheduleNextStatusUploadImmediately(); // Returns true if the next status upload has been scheduled successfully.
// Returns false if there is already an ongoing status report.
bool ScheduleNextStatusUploadImmediately();
const DeviceStatusCollector* device_status_collector() const { const DeviceStatusCollector* device_status_collector() const {
return collector_.get(); return collector_.get();
...@@ -77,8 +79,9 @@ class StatusUploader : public MediaCaptureDevicesDispatcher::Observer { ...@@ -77,8 +79,9 @@ class StatusUploader : public MediaCaptureDevicesDispatcher::Observer {
void OnUploadCompleted(bool success); void OnUploadCompleted(bool success);
// Helper method that figures out when the next status upload should // Helper method that figures out when the next status upload should
// be scheduled. // be scheduled. Returns true if the next status upload has been scheduled
void ScheduleNextStatusUpload(bool immediately = false); // successfully, returns false if there is already an ongoing status report.
bool ScheduleNextStatusUpload(bool immediately = false);
// Updates the upload frequency from settings and schedules a new upload // Updates the upload frequency from settings and schedules a new upload
// if appropriate. // if appropriate.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment