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

Side by Side Diff: mojo/shell/data_pipe_peek.cc

Issue 1543603002: Switch to standard integer types in mojo/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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
« no previous file with comments | « mojo/shell/data_pipe_peek.h ('k') | mojo/shell/data_pipe_peek_unittest.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 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 #include "mojo/shell/data_pipe_peek.h" 5 #include "mojo/shell/data_pipe_peek.h"
6 6
7 #include <stddef.h>
7 #include <stdint.h> 8 #include <stdint.h>
8 9
9 #include <algorithm> 10 #include <algorithm>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 14
14 namespace mojo { 15 namespace mojo {
15 namespace shell { 16 namespace shell {
16 17
(...skipping 19 matching lines...) Expand all
36 if (num_bytes_read > 0 && last_number_bytes_read_ >= num_bytes_read) 37 if (num_bytes_read > 0 && last_number_bytes_read_ >= num_bytes_read)
37 return false; 38 return false;
38 last_number_bytes_read_ = num_bytes_read; 39 last_number_bytes_read_ = num_bytes_read;
39 40
40 MojoTimeTicks now(GetTimeTicksNow()); 41 MojoTimeTicks now(GetTimeTicksNow());
41 if (now > deadline_) 42 if (now > deadline_)
42 return false; 43 return false;
43 44
44 MojoTimeTicks sleep_time = 45 MojoTimeTicks sleep_time =
45 (deadline_ == 0) ? kMaxSleepMicros 46 (deadline_ == 0) ? kMaxSleepMicros
46 : std::min<int64>(deadline_ - now, kMaxSleepMicros); 47 : std::min<int64_t>(deadline_ - now, kMaxSleepMicros);
47 base::PlatformThread::Sleep(base::TimeDelta::FromMicroseconds(sleep_time)); 48 base::PlatformThread::Sleep(base::TimeDelta::FromMicroseconds(sleep_time));
48 return true; 49 return true;
49 } 50 }
50 51
51 private: 52 private:
52 static const MojoTimeTicks kMaxSleepMicros = 1000 * 10; // 10 ms 53 static const MojoTimeTicks kMaxSleepMicros = 1000 * 10; // 10 ms
53 54
54 const MojoTimeTicks deadline_; // 0 => MOJO_DEADLINE_INDEFINITE 55 const MojoTimeTicks deadline_; // 0 => MOJO_DEADLINE_INDEFINITE
55 uint32_t last_number_bytes_read_; 56 uint32_t last_number_bytes_read_;
56 57
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 bool BlockingPeekLine(DataPipeConsumerHandle source, 154 bool BlockingPeekLine(DataPipeConsumerHandle source,
154 std::string* line, 155 std::string* line,
155 size_t max_line_length, 156 size_t max_line_length,
156 MojoDeadline timeout) { 157 MojoDeadline timeout) {
157 PeekFunc peek_line = base::Bind(PeekLine, max_line_length); 158 PeekFunc peek_line = base::Bind(PeekLine, max_line_length);
158 return BlockingPeekHelper(source, line, timeout, peek_line); 159 return BlockingPeekHelper(source, line, timeout, peek_line);
159 } 160 }
160 161
161 } // namespace shell 162 } // namespace shell
162 } // namespace mojo 163 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/data_pipe_peek.h ('k') | mojo/shell/data_pipe_peek_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698