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

Side by Side Diff: chrome/browser/media_galleries/fileapi/av_scanning_file_validator.cc

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/media_galleries/fileapi/av_scanning_file_validator.h" 5 #include "chrome/browser/media_galleries/fileapi/av_scanning_file_validator.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #endif 10 #endif
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 19
20 #if defined(OS_WIN) 20 #if defined(OS_WIN)
21 #include "base/win/scoped_comptr.h" 21 #include "base/win/scoped_comptr.h"
22 #endif 22 #endif
23 23
24 using content::BrowserThread; 24 using content::BrowserThread;
25 25
26 namespace { 26 namespace {
27 27
28 #if defined(OS_WIN) 28 #if defined(OS_WIN)
29 base::PlatformFileError ScanFile( 29 base::File::Error ScanFile(const base::FilePath& dest_platform_path) {
30 const base::FilePath& dest_platform_path) {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
32 31
33 base::win::ScopedComPtr<IAttachmentExecute> attachment_services; 32 base::win::ScopedComPtr<IAttachmentExecute> attachment_services;
34 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); 33 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices);
35 34
36 if (FAILED(hr)) { 35 if (FAILED(hr)) {
37 // The thread must have COM initialized. 36 // The thread must have COM initialized.
38 DCHECK_NE(CO_E_NOTINITIALIZED, hr); 37 DCHECK_NE(CO_E_NOTINITIALIZED, hr);
39 return base::PLATFORM_FILE_ERROR_SECURITY; 38 return base::File::FILE_ERROR_SECURITY;
40 } 39 }
41 40
42 hr = attachment_services->SetLocalPath(dest_platform_path.value().c_str()); 41 hr = attachment_services->SetLocalPath(dest_platform_path.value().c_str());
43 if (FAILED(hr)) 42 if (FAILED(hr))
44 return base::PLATFORM_FILE_ERROR_SECURITY; 43 return base::File::FILE_ERROR_SECURITY;
45 44
46 // A failure in the Save() call below could result in the downloaded file 45 // A failure in the Save() call below could result in the downloaded file
47 // being deleted. 46 // being deleted.
48 HRESULT scan_result = attachment_services->Save(); 47 HRESULT scan_result = attachment_services->Save();
49 if (scan_result == S_OK) 48 if (scan_result == S_OK)
50 return base::PLATFORM_FILE_OK; 49 return base::File::FILE_OK;
51 50
52 return base::PLATFORM_FILE_ERROR_SECURITY; 51 return base::File::FILE_ERROR_SECURITY;
53 } 52 }
54 #endif 53 #endif
55 54
56 } // namespace 55 } // namespace
57 56
58 AVScanningFileValidator::~AVScanningFileValidator() {} 57 AVScanningFileValidator::~AVScanningFileValidator() {}
59 58
60 void AVScanningFileValidator::StartPostWriteValidation( 59 void AVScanningFileValidator::StartPostWriteValidation(
61 const base::FilePath& dest_platform_path, 60 const base::FilePath& dest_platform_path,
62 const ResultCallback& result_callback) { 61 const ResultCallback& result_callback) {
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
64 63
65 #if defined(OS_WIN) 64 #if defined(OS_WIN)
66 BrowserThread::PostTaskAndReplyWithResult( 65 BrowserThread::PostTaskAndReplyWithResult(
67 BrowserThread::FILE, 66 BrowserThread::FILE,
68 FROM_HERE, 67 FROM_HERE,
69 base::Bind(&ScanFile, dest_platform_path), 68 base::Bind(&ScanFile, dest_platform_path),
70 result_callback); 69 result_callback);
71 #else 70 #else
72 result_callback.Run(base::PLATFORM_FILE_OK); 71 result_callback.Run(base::File::FILE_OK);
73 #endif 72 #endif
74 } 73 }
75 74
76 AVScanningFileValidator::AVScanningFileValidator() { 75 AVScanningFileValidator::AVScanningFileValidator() {
77 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698