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

Side by Side Diff: chrome/browser/media_galleries/fileapi/safe_audio_video_checker.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, 10 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/safe_audio_video_checker.h" 5 #include "chrome/browser/media_galleries/fileapi/safe_audio_video_checker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 16 matching lines...) Expand all
27 } 27 }
28 28
29 void SafeAudioVideoChecker::Start() { 29 void SafeAudioVideoChecker::Start() {
30 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 30 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
31 if (state_ != INITIAL_STATE) 31 if (state_ != INITIAL_STATE)
32 return; 32 return;
33 state_ = PINGED_STATE; 33 state_ = PINGED_STATE;
34 34
35 DCHECK(file_closer_); 35 DCHECK(file_closer_);
36 if (*file_closer_.get() == base::kInvalidPlatformFileValue) { 36 if (*file_closer_.get() == base::kInvalidPlatformFileValue) {
37 callback_.Run(base::PLATFORM_FILE_ERROR_SECURITY); 37 callback_.Run(base::File::FILE_ERROR_SECURITY);
38 state_ = FINISHED_STATE; 38 state_ = FINISHED_STATE;
39 return; 39 return;
40 } 40 }
41 41
42 utility_process_host_ = content::UtilityProcessHost::Create( 42 utility_process_host_ = content::UtilityProcessHost::Create(
43 this, base::MessageLoopProxy::current())->AsWeakPtr(); 43 this, base::MessageLoopProxy::current())->AsWeakPtr();
44 utility_process_host_->Send(new ChromeUtilityMsg_StartupPing); 44 utility_process_host_->Send(new ChromeUtilityMsg_StartupPing);
45 } 45 }
46 46
47 SafeAudioVideoChecker::~SafeAudioVideoChecker() {} 47 SafeAudioVideoChecker::~SafeAudioVideoChecker() {}
(...skipping 14 matching lines...) Expand all
62 utility_process_host_->Send(new ChromeUtilityMsg_CheckMediaFile( 62 utility_process_host_->Send(new ChromeUtilityMsg_CheckMediaFile(
63 kFileDecodeTimeInMS, file_for_transit)); 63 kFileDecodeTimeInMS, file_for_transit));
64 } 64 }
65 65
66 void SafeAudioVideoChecker::OnCheckingFinished(bool valid) { 66 void SafeAudioVideoChecker::OnCheckingFinished(bool valid) {
67 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 67 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
68 if (state_ != STARTED_STATE) 68 if (state_ != STARTED_STATE)
69 return; 69 return;
70 state_ = FINISHED_STATE; 70 state_ = FINISHED_STATE;
71 71
72 callback_.Run(valid ? base::PLATFORM_FILE_OK 72 callback_.Run(valid ? base::File::FILE_OK :
73 : base::PLATFORM_FILE_ERROR_SECURITY); 73 base::File::FILE_ERROR_SECURITY);
74 } 74 }
75 75
76 void SafeAudioVideoChecker::OnProcessCrashed(int exit_code) { 76 void SafeAudioVideoChecker::OnProcessCrashed(int exit_code) {
77 OnCheckingFinished(false); 77 OnCheckingFinished(false);
78 } 78 }
79 79
80 bool SafeAudioVideoChecker::OnMessageReceived(const IPC::Message& message) { 80 bool SafeAudioVideoChecker::OnMessageReceived(const IPC::Message& message) {
81 bool handled = true; 81 bool handled = true;
82 IPC_BEGIN_MESSAGE_MAP(SafeAudioVideoChecker, message) 82 IPC_BEGIN_MESSAGE_MAP(SafeAudioVideoChecker, message)
83 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ProcessStarted, 83 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ProcessStarted,
84 OnProcessStarted) 84 OnProcessStarted)
85 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_CheckMediaFile_Finished, 85 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_CheckMediaFile_Finished,
86 OnCheckingFinished) 86 OnCheckingFinished)
87 IPC_MESSAGE_UNHANDLED(handled = false) 87 IPC_MESSAGE_UNHANDLED(handled = false)
88 IPC_END_MESSAGE_MAP() 88 IPC_END_MESSAGE_MAP()
89 return handled; 89 return handled;
90 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698