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

Side by Side Diff: components/nacl/browser/nacl_process_host.cc

Issue 56833003: Use base::PostTaskAndReplyWithResults() in more places. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, fix clang error Created 7 years, 1 month 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 | « components/nacl/browser/nacl_process_host.h ('k') | content/browser/browser_thread_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 "components/nacl/browser/nacl_process_host.h" 5 #include "components/nacl/browser/nacl_process_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 265
266 NaClProcessHost::~NaClProcessHost() { 266 NaClProcessHost::~NaClProcessHost() {
267 // Report exit status only if the process was successfully started. 267 // Report exit status only if the process was successfully started.
268 if (process_->GetData().handle != base::kNullProcessHandle) { 268 if (process_->GetData().handle != base::kNullProcessHandle) {
269 int exit_code = 0; 269 int exit_code = 0;
270 process_->GetTerminationStatus(false /* known_dead */, &exit_code); 270 process_->GetTerminationStatus(false /* known_dead */, &exit_code);
271 std::string message = 271 std::string message =
272 base::StringPrintf("NaCl process exited with status %i (0x%x)", 272 base::StringPrintf("NaCl process exited with status %i (0x%x)",
273 exit_code, exit_code); 273 exit_code, exit_code);
274 if (exit_code == 0) { 274 if (exit_code == 0) {
275 LOG(INFO) << message; 275 VLOG(1) << message;
276 } else { 276 } else {
277 LOG(ERROR) << message; 277 LOG(ERROR) << message;
278 } 278 }
279 } 279 }
280 280
281 if (internal_->socket_for_renderer != NACL_INVALID_HANDLE) { 281 if (internal_->socket_for_renderer != NACL_INVALID_HANDLE) {
282 if (NaClClose(internal_->socket_for_renderer) != 0) { 282 if (NaClClose(internal_->socket_for_renderer) != 0) {
283 NOTREACHED() << "NaClClose() failed"; 283 NOTREACHED() << "NaClClose() failed";
284 } 284 }
285 } 285 }
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 868 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
869 *result = nacl_browser->QueryKnownToValidate(signature, off_the_record_); 869 *result = nacl_browser->QueryKnownToValidate(signature, off_the_record_);
870 } 870 }
871 871
872 void NaClProcessHost::OnSetKnownToValidate(const std::string& signature) { 872 void NaClProcessHost::OnSetKnownToValidate(const std::string& signature) {
873 NaClBrowser::GetInstance()->SetKnownToValidate( 873 NaClBrowser::GetInstance()->SetKnownToValidate(
874 signature, off_the_record_); 874 signature, off_the_record_);
875 } 875 }
876 876
877 void NaClProcessHost::FileResolved( 877 void NaClProcessHost::FileResolved(
878 base::PlatformFile* file,
879 const base::FilePath& file_path, 878 const base::FilePath& file_path,
880 IPC::Message* reply_msg) { 879 IPC::Message* reply_msg,
881 if (*file != base::kInvalidPlatformFileValue) { 880 const base::PlatformFile& file) {
881 if (file != base::kInvalidPlatformFileValue) {
882 IPC::PlatformFileForTransit handle = IPC::GetFileHandleForProcess( 882 IPC::PlatformFileForTransit handle = IPC::GetFileHandleForProcess(
883 *file, 883 file,
884 process_->GetData().handle, 884 process_->GetData().handle,
885 true /* close_source */); 885 true /* close_source */);
886 NaClProcessMsg_ResolveFileToken::WriteReplyParams( 886 NaClProcessMsg_ResolveFileToken::WriteReplyParams(
887 reply_msg, 887 reply_msg,
888 handle, 888 handle,
889 file_path); 889 file_path);
890 } else { 890 } else {
891 NaClProcessMsg_ResolveFileToken::WriteReplyParams( 891 NaClProcessMsg_ResolveFileToken::WriteReplyParams(
892 reply_msg, 892 reply_msg,
893 IPC::InvalidPlatformFileForTransit(), 893 IPC::InvalidPlatformFileForTransit(),
894 base::FilePath(FILE_PATH_LITERAL(""))); 894 base::FilePath());
895 } 895 }
896 Send(reply_msg); 896 Send(reply_msg);
897 } 897 }
898 898
899 void NaClProcessHost::OnResolveFileToken(uint64 file_token_lo, 899 void NaClProcessHost::OnResolveFileToken(uint64 file_token_lo,
900 uint64 file_token_hi, 900 uint64 file_token_hi,
901 IPC::Message* reply_msg) { 901 IPC::Message* reply_msg) {
902 // Was the file registered? 902 // Was the file registered?
903 // 903 //
904 // Note that the file path cache is of bounded size, and old entries can get 904 // Note that the file path cache is of bounded size, and old entries can get
(...skipping 16 matching lines...) Expand all
921 // while the load is in flight. 921 // while the load is in flight.
922 // 922 //
923 // TODO(ncbray): track behavior with UMA. If entries are getting evicted or 923 // TODO(ncbray): track behavior with UMA. If entries are getting evicted or
924 // bogus keys are getting queried, this would be good to know. 924 // bogus keys are getting queried, this would be good to know.
925 base::FilePath file_path; 925 base::FilePath file_path;
926 if (!NaClBrowser::GetInstance()->GetFilePath( 926 if (!NaClBrowser::GetInstance()->GetFilePath(
927 file_token_lo, file_token_hi, &file_path)) { 927 file_token_lo, file_token_hi, &file_path)) {
928 NaClProcessMsg_ResolveFileToken::WriteReplyParams( 928 NaClProcessMsg_ResolveFileToken::WriteReplyParams(
929 reply_msg, 929 reply_msg,
930 IPC::InvalidPlatformFileForTransit(), 930 IPC::InvalidPlatformFileForTransit(),
931 base::FilePath(FILE_PATH_LITERAL(""))); 931 base::FilePath());
932 Send(reply_msg); 932 Send(reply_msg);
933 return; 933 return;
934 } 934 }
935 935
936 // Scratch space to share between the callbacks.
937 base::PlatformFile* data = new base::PlatformFile();
938
939 // Open the file. 936 // Open the file.
940 if (!content::BrowserThread::PostBlockingPoolTaskAndReply( 937 if (!base::PostTaskAndReplyWithResult(
938 content::BrowserThread::GetBlockingPool(),
941 FROM_HERE, 939 FROM_HERE,
942 base::Bind(OpenNaClExecutableImpl, 940 base::Bind(OpenNaClExecutableImpl, file_path),
943 file_path, data),
944 base::Bind(&NaClProcessHost::FileResolved, 941 base::Bind(&NaClProcessHost::FileResolved,
945 weak_factory_.GetWeakPtr(), 942 weak_factory_.GetWeakPtr(),
946 base::Owned(data),
947 file_path, 943 file_path,
948 reply_msg))) { 944 reply_msg))) {
949 NaClProcessMsg_ResolveFileToken::WriteReplyParams( 945 NaClProcessMsg_ResolveFileToken::WriteReplyParams(
950 reply_msg, 946 reply_msg,
951 IPC::InvalidPlatformFileForTransit(), 947 IPC::InvalidPlatformFileForTransit(),
952 base::FilePath(FILE_PATH_LITERAL(""))); 948 base::FilePath());
953 Send(reply_msg); 949 Send(reply_msg);
954 } 950 }
955 } 951 }
956 952
957 #if defined(OS_WIN) 953 #if defined(OS_WIN)
958 void NaClProcessHost::OnAttachDebugExceptionHandler(const std::string& info, 954 void NaClProcessHost::OnAttachDebugExceptionHandler(const std::string& info,
959 IPC::Message* reply_msg) { 955 IPC::Message* reply_msg) {
960 if (!AttachDebugExceptionHandler(info, reply_msg)) { 956 if (!AttachDebugExceptionHandler(info, reply_msg)) {
961 // Send failure message. 957 // Send failure message.
962 NaClProcessMsg_AttachDebugExceptionHandler::WriteReplyParams(reply_msg, 958 NaClProcessMsg_AttachDebugExceptionHandler::WriteReplyParams(reply_msg,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 process_handle.Take(), info, 1013 process_handle.Take(), info,
1018 base::MessageLoopProxy::current(), 1014 base::MessageLoopProxy::current(),
1019 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1015 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
1020 weak_factory_.GetWeakPtr())); 1016 weak_factory_.GetWeakPtr()));
1021 return true; 1017 return true;
1022 } 1018 }
1023 } 1019 }
1024 #endif 1020 #endif
1025 1021
1026 } // namespace nacl 1022 } // namespace nacl
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_process_host.h ('k') | content/browser/browser_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698