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

Unified Diff: content/browser/download/quarantine_win.cc

Issue 2374793002: [Downloads] Fix UMA recording of invalid results from AttachmentServices (Closed)
Patch Set: . Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/download/quarantine_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/quarantine_win.cc
diff --git a/content/browser/download/quarantine_win.cc b/content/browser/download/quarantine_win.cc
index f45a6942404bbae64aa7af7fea3a74286842f120..59605bf9e6222246956d5346bfe318e0afad320e 100644
--- a/content/browser/download/quarantine_win.cc
+++ b/content/browser/download/quarantine_win.cc
@@ -82,16 +82,6 @@ bool ZoneIdentifierPresentForFile(const base::FilePath& path) {
void RecordAttachmentServicesSaveResult(const base::FilePath& file,
HRESULT hr) {
bool file_exists = base::PathExists(file);
- if (SUCCEEDED(hr)) {
- bool motw_exists = file_exists && ZoneIdentifierPresentForFile(file);
- RecordAttachmentServicesResult(
- file_exists
- ? motw_exists ? AttachmentServicesResult::SUCCESS_WITH_MOTW
- : AttachmentServicesResult::SUCCESS_WITHOUT_MOTW
- : AttachmentServicesResult::SUCCESS_WITHOUT_FILE);
- return;
- }
-
switch (hr) {
case INET_E_SECURITY_PROBLEM:
RecordAttachmentServicesResult(
@@ -107,12 +97,26 @@ void RecordAttachmentServicesSaveResult(const base::FilePath& file,
case E_ACCESSDENIED:
case ERROR_ACCESS_DENIED:
+ // ERROR_ACCESS_DENIED is not a valid HRESULT. However,
+ // IAttachmentExecute::Save() is known to return it and other system error
+ // codes in practice.
RecordAttachmentServicesResult(
file_exists ? AttachmentServicesResult::ACCESS_DENIED_WITH_FILE
: AttachmentServicesResult::ACCESS_DENIED_WITHOUT_FILE);
break;
default:
+ if (SUCCEEDED(hr)) {
+ bool motw_exists = file_exists && ZoneIdentifierPresentForFile(file);
+ RecordAttachmentServicesResult(
+ file_exists
+ ? motw_exists ? AttachmentServicesResult::SUCCESS_WITH_MOTW
+ : AttachmentServicesResult::SUCCESS_WITHOUT_MOTW
+ : AttachmentServicesResult::SUCCESS_WITHOUT_FILE);
+ return;
+ }
+
+ // Failure codes.
RecordAttachmentServicesResult(
file_exists ? AttachmentServicesResult::OTHER_WITH_FILE
: AttachmentServicesResult::OTHER_WITHOUT_FILE);
« no previous file with comments | « no previous file | content/browser/download/quarantine_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698