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

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

Issue 441133003: Media Galleries: Check for invalid files before passing them to the utility process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 void SafeAudioVideoChecker::OnProcessStarted() { 48 void SafeAudioVideoChecker::OnProcessStarted() {
49 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 49 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
50 if (state_ != PINGED_STATE) 50 if (state_ != PINGED_STATE)
51 return; 51 return;
52 state_ = STARTED_STATE; 52 state_ = STARTED_STATE;
53 53
54 if (utility_process_host_->GetData().handle == base::kNullProcessHandle) 54 if (utility_process_host_->GetData().handle == base::kNullProcessHandle)
55 DLOG(ERROR) << "Child process handle is null"; 55 DLOG(ERROR) << "Child process handle is null";
56 IPC::PlatformFileForTransit file_for_transit = 56 IPC::PlatformFileForTransit file_for_transit =
57 IPC::TakeFileHandleForProcess(file_.Pass(), 57 IPC::TakeFileHandleForProcess(file_.Pass(),
rvargas (doing something else) 2014/08/05 23:40:19 nit: seems better to see if file_.IsValid() instea
Lei Zhang 2014/08/05 23:46:38 We already do that on line 35. I suspect maybe Dup
rvargas (doing something else) 2014/08/06 00:08:03 You are absolutely right!.
58 utility_process_host_->GetData().handle); 58 utility_process_host_->GetData().handle);
59 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) {
60 OnCheckingFinished(false /* valid? */);
61 return;
62 }
59 const int64 kFileDecodeTimeInMS = 250; 63 const int64 kFileDecodeTimeInMS = 250;
60 utility_process_host_->Send(new ChromeUtilityMsg_CheckMediaFile( 64 utility_process_host_->Send(new ChromeUtilityMsg_CheckMediaFile(
61 kFileDecodeTimeInMS, file_for_transit)); 65 kFileDecodeTimeInMS, file_for_transit));
62 } 66 }
63 67
64 void SafeAudioVideoChecker::OnCheckingFinished(bool valid) { 68 void SafeAudioVideoChecker::OnCheckingFinished(bool valid) {
65 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 69 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
66 if (state_ != STARTED_STATE) 70 if (state_ != STARTED_STATE)
67 return; 71 return;
68 state_ = FINISHED_STATE; 72 state_ = FINISHED_STATE;
(...skipping 10 matching lines...) Expand all
79 bool handled = true; 83 bool handled = true;
80 IPC_BEGIN_MESSAGE_MAP(SafeAudioVideoChecker, message) 84 IPC_BEGIN_MESSAGE_MAP(SafeAudioVideoChecker, message)
81 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ProcessStarted, 85 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ProcessStarted,
82 OnProcessStarted) 86 OnProcessStarted)
83 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_CheckMediaFile_Finished, 87 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_CheckMediaFile_Finished,
84 OnCheckingFinished) 88 OnCheckingFinished)
85 IPC_MESSAGE_UNHANDLED(handled = false) 89 IPC_MESSAGE_UNHANDLED(handled = false)
86 IPC_END_MESSAGE_MAP() 90 IPC_END_MESSAGE_MAP()
87 return handled; 91 return handled;
88 } 92 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698