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

Side by Side Diff: chrome/browser/process_singleton_posix.cc

Issue 1240183002: Update SplitString calls in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // On Linux, when the user tries to launch a second copy of chrome, we check 5 // On Linux, when the user tries to launch a second copy of chrome, we check
6 // for a socket in the user's profile directory. If the socket file is open we 6 // for a socket in the user's profile directory. If the socket file is open we
7 // send a message to the first chrome browser process with the current 7 // send a message to the first chrome browser process with the current
8 // directory and second process command line flags. The second process then 8 // directory and second process command line flags. The second process then
9 // exits. 9 // exits.
10 // 10 //
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 // Validate the message. The shortest message is kStartToken\0x\0x 677 // Validate the message. The shortest message is kStartToken\0x\0x
678 const size_t kMinMessageLength = arraysize(kStartToken) + 4; 678 const size_t kMinMessageLength = arraysize(kStartToken) + 4;
679 if (bytes_read_ < kMinMessageLength) { 679 if (bytes_read_ < kMinMessageLength) {
680 buf_[bytes_read_] = 0; 680 buf_[bytes_read_] = 0;
681 LOG(ERROR) << "Invalid socket message (wrong length):" << buf_; 681 LOG(ERROR) << "Invalid socket message (wrong length):" << buf_;
682 CleanupAndDeleteSelf(); 682 CleanupAndDeleteSelf();
683 return; 683 return;
684 } 684 }
685 685
686 std::string str(buf_, bytes_read_); 686 std::string str(buf_, bytes_read_);
687 std::vector<std::string> tokens; 687 std::vector<std::string> tokens = base::SplitString(
688 base::SplitString(str, kTokenDelimiter, &tokens); 688 str, std::string(1, kTokenDelimiter),
689 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
689 690
690 if (tokens.size() < 3 || tokens[0] != kStartToken) { 691 if (tokens.size() < 3 || tokens[0] != kStartToken) {
691 LOG(ERROR) << "Wrong message format: " << str; 692 LOG(ERROR) << "Wrong message format: " << str;
692 CleanupAndDeleteSelf(); 693 CleanupAndDeleteSelf();
693 return; 694 return;
694 } 695 }
695 696
696 // Stop the expiration timer to prevent this SocketReader object from being 697 // Stop the expiration timer to prevent this SocketReader object from being
697 // terminated unexpectly. 698 // terminated unexpectly.
698 timer_.Stop(); 699 timer_.Stop();
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 } 1064 }
1064 1065
1065 void ProcessSingleton::KillProcess(int pid) { 1066 void ProcessSingleton::KillProcess(int pid) {
1066 // TODO(james.su@gmail.com): Is SIGKILL ok? 1067 // TODO(james.su@gmail.com): Is SIGKILL ok?
1067 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL); 1068 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL);
1068 // ESRCH = No Such Process (can happen if the other process is already in 1069 // ESRCH = No Such Process (can happen if the other process is already in
1069 // progress of shutting down and finishes before we try to kill it). 1070 // progress of shutting down and finishes before we try to kill it).
1070 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " 1071 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: "
1071 << base::safe_strerror(errno); 1072 << base::safe_strerror(errno);
1072 } 1073 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_preview_pdf_generated_browsertest.cc ('k') | chrome/browser/profiles/profile_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698