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

Side by Side Diff: chromeos/process_proxy/process_output_watcher.cc

Issue 1540803002: Switch to standard integer types in chromeos/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more includes Created 5 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 "chromeos/process_proxy/process_output_watcher.h" 5 #include "chromeos/process_proxy/process_output_watcher.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include <algorithm> 10 #include <algorithm>
8 #include <cstdio> 11 #include <cstdio>
9 #include <cstring> 12 #include <cstring>
10 #include "base/bind.h" 13 #include "base/bind.h"
11 #include "base/location.h" 14 #include "base/location.h"
12 #include "base/logging.h" 15 #include "base/logging.h"
13 #include "base/posix/eintr_wrapper.h" 16 #include "base/posix/eintr_wrapper.h"
14 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
15 #include "base/third_party/icu/icu_utf.h" 18 #include "base/third_party/icu/icu_utf.h"
16 #include "base/thread_task_runner_handle.h" 19 #include "base/thread_task_runner_handle.h"
17 #include "base/time/time.h" 20 #include "base/time/time.h"
18 21
19 namespace { 22 namespace {
20 23
21 // Gets byte size for a UTF8 character given it's leading byte. The character 24 // Gets byte size for a UTF8 character given it's leading byte. The character
22 // size is encoded as number of leading '1' bits in the character's leading 25 // size is encoded as number of leading '1' bits in the character's leading
23 // byte. If the most significant bit is '0', the character is a valid ASCII 26 // byte. If the most significant bit is '0', the character is a valid ASCII
24 // and it's byte size is 1. 27 // and it's byte size is 1.
25 // The method returns 1 if the provided byte is invalid leading byte. 28 // The method returns 1 if the provided byte is invalid leading byte.
26 size_t UTF8SizeFromLeadingByte(uint8 leading_byte) { 29 size_t UTF8SizeFromLeadingByte(uint8_t leading_byte) {
27 size_t byte_count = 0; 30 size_t byte_count = 0;
28 uint8 mask = 1 << 7; 31 uint8_t mask = 1 << 7;
29 uint8 error_mask = 1 << (7 - CBU8_MAX_LENGTH); 32 uint8_t error_mask = 1 << (7 - CBU8_MAX_LENGTH);
30 while (leading_byte & mask) { 33 while (leading_byte & mask) {
31 if (mask & error_mask) 34 if (mask & error_mask)
32 return 1; 35 return 1;
33 mask >>= 1; 36 mask >>= 1;
34 ++byte_count; 37 ++byte_count;
35 } 38 }
36 return byte_count ? byte_count : 1; 39 return byte_count ? byte_count : 1;
37 } 40 }
38 41
39 } // namespace 42 } // namespace
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // update the buffer size accordingly. 163 // update the buffer size accordingly.
161 if (output_to_report < read_buffer_size_) { 164 if (output_to_report < read_buffer_size_) {
162 for (size_t i = output_to_report; i < read_buffer_size_; ++i) { 165 for (size_t i = output_to_report; i < read_buffer_size_; ++i) {
163 read_buffer_[i - output_to_report] = read_buffer_[i]; 166 read_buffer_[i - output_to_report] = read_buffer_[i];
164 } 167 }
165 } 168 }
166 read_buffer_size_ -= output_to_report; 169 read_buffer_size_ -= output_to_report;
167 } 170 }
168 171
169 } // namespace chromeos 172 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/process_proxy/process_output_watcher.h ('k') | chromeos/process_proxy/process_output_watcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698