Chromium Code Reviews| Index: net/http/http_util.h |
| diff --git a/net/http/http_util.h b/net/http/http_util.h |
| index 2f5bd85a667ba54a0ae66ee738a0cfc941f240a3..a9082d645878f6eca967177352f9bfb7871f05ed 100644 |
| --- a/net/http/http_util.h |
| +++ b/net/http/http_util.h |
| @@ -26,6 +26,45 @@ class HttpRequestHeaders; |
| class HttpStream; |
| class UploadDataStream; |
| +const char kHttpScheme[] = "http"; |
| +const char kHttpsScheme[] = "https"; |
| +const char kDataScheme[] = "data"; |
| +const int64 kPositionNotSpecified = -1; |
| +const int kHttpOK = 200; |
| +const int kHttpPartialContent = 206; |
| + |
| +// Define the number of bytes in a megabyte. |
| +const size_t kMegabyte = 1024 * 1024; |
| + |
| +// Backward capacity of the buffer, by default 2MB. |
| +const size_t kBackwardCapcity = 2 * kMegabyte; |
| + |
| +// Forward capacity of the buffer, by default 10MB. |
| +const size_t kForwardCapacity = 10 * kMegabyte; |
| + |
| +// The threshold of bytes that we should wait until the data arrives in the |
| +// future instead of restarting a new connection. This number is defined in the |
| +// number of bytes, we should determine this value from typical connection speed |
| +// and amount of time for a suitable wait. Now I just make a guess for this |
| +// number to be 2MB. |
| +// TODO(hclam): determine a better value for this. |
| +const int kForwardWaitThreshold = 2 * kMegabyte; |
| + |
| +// Defines how long we should wait for more data before we declare a connection |
| +// timeout and start a new request. |
| +// TODO(hclam): We should really remove this (crbug.com/64571). |
| +const int kTimeoutMilliseconds = 5000; |
| + |
| +// Defines how many times we should try to read from a buffered resource loader |
| +// before we declare a read error. After each failure of read from a buffered |
| +// resource loader, a new one is created to be read. |
| +const int kReadTrials = 3; |
| + |
| +// BufferedDataSource has an intermediate buffer, this value governs the initial |
| +// size of that buffer. It is set to 32KB because this is a typical read size |
| +// of FFmpeg. |
| +const int kInitialReadBufferSize = 32768; |
|
scherkus (not reviewing)
2010/12/14 18:48:19
I don't think most of these constants belong here
annacc
2010/12/14 21:10:17
OK, I've moved the rest back where they belong, so
annacc
2010/12/14 21:30:44
Scratch the bit about adding ericroman, he's on va
|
| + |
| class HttpUtil { |
| public: |
| // Returns the absolute path of the URL, to be used for the http request. |
| @@ -177,6 +216,15 @@ class HttpUtil { |
| bool enable_full_url, |
| HttpRequestHeaders* request_headers); |
| + // Returns true if |url| operates on HTTP protocol. |
| + static bool IsHttpProtocol(const GURL& url) { |
| + return url.SchemeIs(kHttpScheme) || url.SchemeIs(kHttpsScheme); |
| + } |
| + |
| + static bool IsDataProtocol(const GURL& url) { |
| + return url.SchemeIs(kDataScheme); |
| + } |
| + |
| // Used to iterate over the name/value pairs of HTTP headers. To iterate |
| // over the values in a multi-value header, use ValuesIterator. |
| // See AssembleRawHeaders for joining line continuations (this iterator |