| Index: shell/data_pipe_peek.cc
 | 
| diff --git a/mojo/shell/data_pipe_peek.cc b/shell/data_pipe_peek.cc
 | 
| similarity index 81%
 | 
| rename from mojo/shell/data_pipe_peek.cc
 | 
| rename to shell/data_pipe_peek.cc
 | 
| index c6b041b4bb5cb8c1be118caed403ffb4ed6214a8..82e72a9a2fb98b12e58c105a4398b493b491812e 100644
 | 
| --- a/mojo/shell/data_pipe_peek.cc
 | 
| +++ b/shell/data_pipe_peek.cc
 | 
| @@ -2,7 +2,7 @@
 | 
|  // Use of this source code is governed by a BSD-style license that can be
 | 
|  // found in the LICENSE file.
 | 
|  
 | 
| -#include "mojo/shell/data_pipe_peek.h"
 | 
| +#include "shell/data_pipe_peek.h"
 | 
|  
 | 
|  #include "base/bind.h"
 | 
|  
 | 
| @@ -25,9 +25,8 @@ class PeekSleeper {
 | 
|   public:
 | 
|    explicit PeekSleeper(MojoTimeTicks deadline)
 | 
|        : deadline_(deadline),
 | 
| -        kMaxSleepMicros_(1000 * 10), // 10ms
 | 
| -        last_number_bytes_read_(0) {
 | 
| -  }
 | 
| +        kMaxSleepMicros_(1000 * 10),  // 10ms
 | 
| +        last_number_bytes_read_(0) {}
 | 
|  
 | 
|    bool MaybeSleep(uint32 num_bytes_read) {
 | 
|      if (num_bytes_read > 0 && last_number_bytes_read_ >= num_bytes_read)
 | 
| @@ -38,15 +37,16 @@ class PeekSleeper {
 | 
|      if (now > deadline_)
 | 
|        return false;
 | 
|  
 | 
| -    MojoTimeTicks sleep_time = (deadline_ == 0)
 | 
| -        ? kMaxSleepMicros_
 | 
| -        : std::min<int64>(deadline_ - now, PeekSleeper::kMaxSleepMicros_);
 | 
| +    MojoTimeTicks sleep_time =
 | 
| +        (deadline_ == 0)
 | 
| +            ? kMaxSleepMicros_
 | 
| +            : std::min<int64>(deadline_ - now, PeekSleeper::kMaxSleepMicros_);
 | 
|      base::PlatformThread::Sleep(base::TimeDelta::FromMicroseconds(sleep_time));
 | 
|      return true;
 | 
|    }
 | 
|  
 | 
|   private:
 | 
| -  const MojoTimeTicks deadline_; // 0 => MOJO_DEADLINE_INDEFINITE
 | 
| +  const MojoTimeTicks deadline_;  // 0 => MOJO_DEADLINE_INDEFINITE
 | 
|    const MojoTimeTicks kMaxSleepMicros_;
 | 
|    uint32 last_number_bytes_read_;
 | 
|  
 | 
| @@ -69,8 +69,10 @@ bool BlockingPeekHelper(DataPipeConsumerHandle source,
 | 
|    DCHECK(value);
 | 
|    value->clear();
 | 
|  
 | 
| -  MojoTimeTicks deadline = (timeout == MOJO_DEADLINE_INDEFINITE) ? 0
 | 
| -      : 1 + GetTimeTicksNow() + static_cast<MojoTimeTicks>(timeout);
 | 
| +  MojoTimeTicks deadline =
 | 
| +      (timeout == MOJO_DEADLINE_INDEFINITE)
 | 
| +          ? 0
 | 
| +          : 1 + GetTimeTicksNow() + static_cast<MojoTimeTicks>(timeout);
 | 
|    PeekSleeper sleeper(deadline);
 | 
|  
 | 
|    MojoResult result;
 | 
| @@ -84,9 +86,12 @@ bool BlockingPeekHelper(DataPipeConsumerHandle source,
 | 
|        PeekStatus status = peek_func.Run(buffer, num_bytes, value);
 | 
|        CHECK_EQ(EndReadDataRaw(source, 0), MOJO_RESULT_OK);
 | 
|        switch (status) {
 | 
| -        case PeekStatus::kSuccess: return true;
 | 
| -        case PeekStatus::kFail: return false;
 | 
| -        case PeekStatus::kKeepReading: break;
 | 
| +        case PeekStatus::kSuccess:
 | 
| +          return true;
 | 
| +        case PeekStatus::kFail:
 | 
| +          return false;
 | 
| +        case PeekStatus::kKeepReading:
 | 
| +          break;
 | 
|        }
 | 
|        if (!sleeper.MaybeSleep(num_bytes))
 | 
|          return false;
 | 
| @@ -95,8 +100,7 @@ bool BlockingPeekHelper(DataPipeConsumerHandle source,
 | 
|        if (timeout == MOJO_DEADLINE_INDEFINITE || now < deadline)
 | 
|          result = Wait(source, MOJO_HANDLE_SIGNAL_READABLE, deadline - now);
 | 
|      }
 | 
| -  }
 | 
| -  while(result == MOJO_RESULT_OK);
 | 
| +  } while (result == MOJO_RESULT_OK);
 | 
|  
 | 
|    return false;
 | 
|  }
 | 
| @@ -109,12 +113,12 @@ PeekStatus PeekLine(size_t max_line_length,
 | 
|    size_t max_p_index = std::min<size_t>(buffer_num_bytes, max_line_length);
 | 
|    for (size_t i = 0; i < max_p_index; i++) {
 | 
|      if (p[i] == '\n') {
 | 
| -      *line = std::string(p, i + 1); // Include the trailing newline.
 | 
| +      *line = std::string(p, i + 1);  // Include the trailing newline.
 | 
|        return PeekStatus::kSuccess;
 | 
|      }
 | 
|    }
 | 
| -  return (buffer_num_bytes >= max_line_length)
 | 
| -      ? PeekStatus::kFail : PeekStatus::kKeepReading;
 | 
| +  return (buffer_num_bytes >= max_line_length) ? PeekStatus::kFail
 | 
| +                                               : PeekStatus::kKeepReading;
 | 
|  }
 | 
|  
 | 
|  PeekStatus PeekNBytes(size_t bytes_length,
 | 
| @@ -129,8 +133,7 @@ PeekStatus PeekNBytes(size_t bytes_length,
 | 
|    return PeekStatus::kKeepReading;
 | 
|  }
 | 
|  
 | 
| -} // namespace
 | 
| -
 | 
| +}  // namespace
 | 
|  
 | 
|  bool BlockingPeekNBytes(DataPipeConsumerHandle source,
 | 
|                          std::string* bytes,
 | 
| @@ -148,5 +151,5 @@ bool BlockingPeekLine(DataPipeConsumerHandle source,
 | 
|    return BlockingPeekHelper(source, line, timeout, peek_line);
 | 
|  }
 | 
|  
 | 
| -} // namespace shell
 | 
| -} // namespace mojo
 | 
| +}  // namespace shell
 | 
| +}  // namespace mojo
 | 
| 
 |