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

Side by Side Diff: content/browser/download/base_file_win.cc

Issue 2315613002: Extracted NetLog class's inner enum types into their own enum classes and (Closed)
Patch Set: Ran "git cl format" on code. Much formatting ensued. 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 unified diff | Download patch
« no previous file with comments | « content/browser/download/base_file.cc ('k') | content/browser/download/download_file_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/browser/download/base_file.h" 5 #include "content/browser/download/base_file.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <cguid.h> 8 #include <cguid.h>
9 #include <objbase.h> 9 #include <objbase.h>
10 #include <shellapi.h> 10 #include <shellapi.h>
11 11
12 #include "base/files/file.h" 12 #include "base/files/file.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/guid.h" 14 #include "base/guid.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/threading/thread_restrictions.h" 18 #include "base/threading/thread_restrictions.h"
19 #include "content/browser/download/download_interrupt_reasons_impl.h" 19 #include "content/browser/download/download_interrupt_reasons_impl.h"
20 #include "content/browser/download/download_stats.h" 20 #include "content/browser/download/download_stats.h"
21 #include "content/browser/safe_util_win.h" 21 #include "content/browser/safe_util_win.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "net/log/net_log_event_type.h"
23 24
24 namespace content { 25 namespace content {
25 namespace { 26 namespace {
26 27
27 const int kAllSpecialShFileOperationCodes[] = { 28 const int kAllSpecialShFileOperationCodes[] = {
28 // Should be kept in sync with the case statement below. 29 // Should be kept in sync with the case statement below.
29 ERROR_ACCESS_DENIED, 30 ERROR_ACCESS_DENIED,
30 ERROR_SHARING_VIOLATION, 31 ERROR_SHARING_VIOLATION,
31 ERROR_INVALID_PARAMETER, 32 ERROR_INVALID_PARAMETER,
32 0x71, 33 0x71,
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return interrupt_reason; 353 return interrupt_reason;
353 } 354 }
354 355
355 DownloadInterruptReason BaseFile::AnnotateWithSourceInformation( 356 DownloadInterruptReason BaseFile::AnnotateWithSourceInformation(
356 const std::string& client_guid, 357 const std::string& client_guid,
357 const GURL& source_url, 358 const GURL& source_url,
358 const GURL& referrer_url) { 359 const GURL& referrer_url) {
359 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 360 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
360 DCHECK(!detached_); 361 DCHECK(!detached_);
361 362
362 bound_net_log_.BeginEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); 363 bound_net_log_.BeginEvent(net::NetLogEventType::DOWNLOAD_FILE_ANNOTATED);
363 DownloadInterruptReason result = DOWNLOAD_INTERRUPT_REASON_NONE; 364 DownloadInterruptReason result = DOWNLOAD_INTERRUPT_REASON_NONE;
364 std::string braces_guid = "{" + client_guid + "}"; 365 std::string braces_guid = "{" + client_guid + "}";
365 GUID guid = GUID_NULL; 366 GUID guid = GUID_NULL;
366 if (base::IsValidGUID(client_guid)) { 367 if (base::IsValidGUID(client_guid)) {
367 HRESULT hr = CLSIDFromString( 368 HRESULT hr = CLSIDFromString(
368 base::UTF8ToUTF16(braces_guid).c_str(), &guid); 369 base::UTF8ToUTF16(braces_guid).c_str(), &guid);
369 if (FAILED(hr)) 370 if (FAILED(hr))
370 guid = GUID_NULL; 371 guid = GUID_NULL;
371 } 372 }
372 373
(...skipping 12 matching lines...) Expand all
385 // we don't surface the error to the user. 386 // we don't surface the error to the user.
386 if (!base::PathExists(full_path_)) { 387 if (!base::PathExists(full_path_)) {
387 DCHECK(FAILED(hr)); 388 DCHECK(FAILED(hr));
388 result = MapScanAndSaveErrorCodeToInterruptReason(hr); 389 result = MapScanAndSaveErrorCodeToInterruptReason(hr);
389 if (result == DOWNLOAD_INTERRUPT_REASON_NONE) { 390 if (result == DOWNLOAD_INTERRUPT_REASON_NONE) {
390 RecordDownloadCount(FILE_MISSING_AFTER_SUCCESSFUL_SCAN_COUNT); 391 RecordDownloadCount(FILE_MISSING_AFTER_SUCCESSFUL_SCAN_COUNT);
391 result = DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED; 392 result = DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED;
392 } 393 }
393 LogInterruptReason("ScanAndSaveDownloadedFile", hr, result); 394 LogInterruptReason("ScanAndSaveDownloadedFile", hr, result);
394 } 395 }
395 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); 396 bound_net_log_.EndEvent(net::NetLogEventType::DOWNLOAD_FILE_ANNOTATED);
396 return result; 397 return result;
397 } 398 }
398 399
399 } // namespace content 400 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/base_file.cc ('k') | content/browser/download/download_file_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698