Commit 28140ebf authored by cschuet's avatar cschuet Committed by Commit bot

Add invalid url failure to screencapture command

Replaces the DCHECK for validity of the upload url with an explicit runtime
check. If the check fails the client sends a FAILURE_INVALID_URL error to
DMServer and logs a message to the ui log.

BUG=480982

Review URL: https://codereview.chromium.org/1138063006

Cr-Commit-Position: refs/heads/master@{#329388}
parent c90c14a6
......@@ -142,14 +142,13 @@ bool DeviceCommandScreenshotJob::ParseCommandPayload(
scoped_ptr<base::Value> root(base::JSONReader().ReadToValue(command_payload));
if (!root.get())
return false;
base::DictionaryValue* payload;
base::DictionaryValue* payload = nullptr;
if (!root->GetAsDictionary(&payload))
return false;
std::string upload_url;
if (!payload->GetString(kUploadUrlFieldName, &upload_url))
return false;
upload_url_ = GURL(upload_url);
DCHECK(upload_url_.is_valid()) << upload_url_ << " is not a valid URL";
return true;
}
......@@ -195,12 +194,23 @@ void DeviceCommandScreenshotJob::RunImpl(
aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows();
// Immediately fail if the upload url is invalid.
if (!upload_url_.is_valid()) {
LOG(ERROR) << upload_url_ << " is not a valid URL.";
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(failed_callback_, base::Passed(make_scoped_ptr(
new Payload(FAILURE_INVALID_URL)))));
return;
}
// Immediately fail if there are no attached screens.
if (root_windows.size() == 0) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(failed_callback_, base::Passed(make_scoped_ptr(new Payload(
FAILURE_SCREENSHOT_ACQUISITION)))));
return;
}
// Post tasks to the sequenced worker pool for taking screenshots on each
......
......@@ -53,7 +53,10 @@ class DeviceCommandScreenshotJob : public RemoteCommandJob,
FAILURE_SERVER = 4,
// Failed due to a client-side error.
FAILURE_CLIENT = 5
FAILURE_CLIENT = 5,
// Failed due to an invalid upload url.
FAILURE_INVALID_URL = 6
};
// A delegate interface used by DeviceCommandScreenshotJob to retrieve its
......
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