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

Side by Side Diff: content/browser/zygote_host/zygote_host_impl_linux.cc

Issue 818833004: Remove deprecated methods from Pickle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years 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
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/zygote_host/zygote_host_impl_linux.h" 5 #include "content/browser/zygote_host/zygote_host_impl_linux.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <sys/socket.h> 8 #include <sys/socket.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 return base::kNullProcessHandle; 362 return base::kNullProcessHandle;
363 } 363 }
364 364
365 // Read the reply, which pickles the PID and an optional UMA enumeration. 365 // Read the reply, which pickles the PID and an optional UMA enumeration.
366 static const unsigned kMaxReplyLength = 2048; 366 static const unsigned kMaxReplyLength = 2048;
367 char buf[kMaxReplyLength]; 367 char buf[kMaxReplyLength];
368 const ssize_t len = ReadReply(buf, sizeof(buf)); 368 const ssize_t len = ReadReply(buf, sizeof(buf));
369 369
370 Pickle reply_pickle(buf, len); 370 Pickle reply_pickle(buf, len);
371 PickleIterator iter(reply_pickle); 371 PickleIterator iter(reply_pickle);
372 if (len <= 0 || !reply_pickle.ReadInt(&iter, &pid)) 372 if (len <= 0 || !iter.ReadInt(&pid))
373 return base::kNullProcessHandle; 373 return base::kNullProcessHandle;
374 374
375 // If there is a nonempty UMA name string, then there is a UMA 375 // If there is a nonempty UMA name string, then there is a UMA
376 // enumeration to record. 376 // enumeration to record.
377 std::string uma_name; 377 std::string uma_name;
378 int uma_sample; 378 int uma_sample;
379 int uma_boundary_value; 379 int uma_boundary_value;
380 if (reply_pickle.ReadString(&iter, &uma_name) && 380 if (iter.ReadString(&uma_name) &&
381 !uma_name.empty() && 381 !uma_name.empty() &&
382 reply_pickle.ReadInt(&iter, &uma_sample) && 382 iter.ReadInt(&uma_sample) &&
383 reply_pickle.ReadInt(&iter, &uma_boundary_value)) { 383 iter.ReadInt(&uma_boundary_value)) {
384 // We cannot use the UMA_HISTOGRAM_ENUMERATION macro here, 384 // We cannot use the UMA_HISTOGRAM_ENUMERATION macro here,
385 // because that's only for when the name is the same every time. 385 // because that's only for when the name is the same every time.
386 // Here we're using whatever name we got from the other side. 386 // Here we're using whatever name we got from the other side.
387 // But since it's likely that the same one will be used repeatedly 387 // But since it's likely that the same one will be used repeatedly
388 // (even though it's not guaranteed), we cache it here. 388 // (even though it's not guaranteed), we cache it here.
389 static base::HistogramBase* uma_histogram; 389 static base::HistogramBase* uma_histogram;
390 if (!uma_histogram || uma_histogram->histogram_name() != uma_name) { 390 if (!uma_histogram || uma_histogram->histogram_name() != uma_name) {
391 uma_histogram = base::LinearHistogram::FactoryGet( 391 uma_histogram = base::LinearHistogram::FactoryGet(
392 uma_name, 1, 392 uma_name, 1,
393 uma_boundary_value, 393 uma_boundary_value,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 int status = base::TERMINATION_STATUS_NORMAL_TERMINATION; 525 int status = base::TERMINATION_STATUS_NORMAL_TERMINATION;
526 526
527 if (len == -1) { 527 if (len == -1) {
528 LOG(WARNING) << "Error reading message from zygote: " << errno; 528 LOG(WARNING) << "Error reading message from zygote: " << errno;
529 } else if (len == 0) { 529 } else if (len == 0) {
530 LOG(WARNING) << "Socket closed prematurely."; 530 LOG(WARNING) << "Socket closed prematurely.";
531 } else { 531 } else {
532 Pickle read_pickle(buf, len); 532 Pickle read_pickle(buf, len);
533 int tmp_status, tmp_exit_code; 533 int tmp_status, tmp_exit_code;
534 PickleIterator iter(read_pickle); 534 PickleIterator iter(read_pickle);
535 if (!read_pickle.ReadInt(&iter, &tmp_status) || 535 if (!iter.ReadInt(&tmp_status) || !iter.ReadInt(&tmp_exit_code)) {
536 !read_pickle.ReadInt(&iter, &tmp_exit_code)) {
537 LOG(WARNING) 536 LOG(WARNING)
538 << "Error parsing GetTerminationStatus response from zygote."; 537 << "Error parsing GetTerminationStatus response from zygote.";
539 } else { 538 } else {
540 if (exit_code) 539 if (exit_code)
541 *exit_code = tmp_exit_code; 540 *exit_code = tmp_exit_code;
542 status = tmp_status; 541 status = tmp_status;
543 } 542 }
544 } 543 }
545 544
546 if (status != base::TERMINATION_STATUS_STILL_RUNNING) { 545 if (status != base::TERMINATION_STATUS_STILL_RUNNING) {
547 ZygoteChildDied(handle); 546 ZygoteChildDied(handle);
548 } 547 }
549 return static_cast<base::TerminationStatus>(status); 548 return static_cast<base::TerminationStatus>(status);
550 } 549 }
551 550
552 pid_t ZygoteHostImpl::GetPid() const { 551 pid_t ZygoteHostImpl::GetPid() const {
553 return pid_; 552 return pid_;
554 } 553 }
555 554
556 int ZygoteHostImpl::GetSandboxStatus() const { 555 int ZygoteHostImpl::GetSandboxStatus() const {
557 if (have_read_sandbox_status_word_) 556 if (have_read_sandbox_status_word_)
558 return sandbox_status_; 557 return sandbox_status_;
559 return 0; 558 return 0;
560 } 559 }
561 560
562 } // namespace content 561 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_aura.cc ('k') | content/child/resource_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698