summaryrefslogtreecommitdiffstats
path: root/mojo/shell/data_pipe_peek.h
blob: 215cc477a94237cd54ddf5a2d3869550a412d902 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MOJO_SHELL_DATA_PIPE_PEEK_H_
#define MOJO_SHELL_DATA_PIPE_PEEK_H_

#include <stddef.h>

#include <string>

#include "mojo/public/cpp/system/core.h"

namespace mojo {
namespace shell {

// The Peek functions are only intended to be used by the
// DyanmicApplicationLoader class for discovering the type of a
// URL response. They are a stopgap to be replaced by real support
// in the DataPipe classes.

// Return true and the first newline terminated line from source. Return false
// if more than max_line_length bytes are scanned without seeing a newline, or
// if the timeout is exceeded.
bool BlockingPeekLine(DataPipeConsumerHandle source,
                      std::string* line,
                      size_t max_line_length,
                      MojoDeadline timeout);

// Return true and the first bytes_length bytes from source. Return false
// if the timeout is exceeded.
bool BlockingPeekNBytes(DataPipeConsumerHandle source,
                        std::string* bytes,
                        size_t bytes_length,
                        MojoDeadline timeout);

}  // namespace shell
}  // namespace mojo

#endif  // MOJO_SHELL_DATA_PIPE_PEEK_H_