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

Side by Side Diff: net/http/http_byte_range.cc

Issue 1800003: Auto-format style pass over files. (Closed)
Patch Set: Remove trailing whitespace. Created 10 years, 7 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 | « net/http/http_auth_unittest.cc ('k') | net/http/http_cache.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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "net/http/http_byte_range.h" 7 #include "net/http/http_byte_range.h"
8 8
9 namespace { 9 namespace {
10 10
(...skipping 18 matching lines...) Expand all
29 return first_byte_position_ != kPositionNotSpecified; 29 return first_byte_position_ != kPositionNotSpecified;
30 } 30 }
31 31
32 bool HttpByteRange::HasLastBytePosition() const { 32 bool HttpByteRange::HasLastBytePosition() const {
33 return last_byte_position_ != kPositionNotSpecified; 33 return last_byte_position_ != kPositionNotSpecified;
34 } 34 }
35 35
36 bool HttpByteRange::IsValid() const { 36 bool HttpByteRange::IsValid() const {
37 if (suffix_length_ > 0) 37 if (suffix_length_ > 0)
38 return true; 38 return true;
39 return first_byte_position_ >= 0 && 39 return (first_byte_position_ >= 0 &&
40 (last_byte_position_ == kPositionNotSpecified || 40 (last_byte_position_ == kPositionNotSpecified ||
41 last_byte_position_ >= first_byte_position_); 41 last_byte_position_ >= first_byte_position_));
42 } 42 }
43 43
44 bool HttpByteRange::ComputeBounds(int64 size) { 44 bool HttpByteRange::ComputeBounds(int64 size) {
45 if (size < 0) 45 if (size < 0)
46 return false; 46 return false;
47 if (has_computed_bounds_) 47 if (has_computed_bounds_)
48 return false; 48 return false;
49 has_computed_bounds_ = true; 49 has_computed_bounds_ = true;
50 50
51 // Empty values. 51 // Empty values.
52 if (!HasFirstBytePosition() && 52 if (!HasFirstBytePosition() &&
53 !HasLastBytePosition() && 53 !HasLastBytePosition() &&
54 !IsSuffixByteRange()) { 54 !IsSuffixByteRange()) {
55 first_byte_position_ = 0; 55 first_byte_position_ = 0;
56 last_byte_position_ = size - 1; 56 last_byte_position_ = size - 1;
57 return true; 57 return true;
58 } 58 }
59 if (!IsValid()) 59 if (!IsValid())
60 return false; 60 return false;
61 if (IsSuffixByteRange()) { 61 if (IsSuffixByteRange()) {
62 first_byte_position_ = size - std::min(size, suffix_length_); 62 first_byte_position_ = size - std::min(size, suffix_length_);
63 last_byte_position_ = size - 1; 63 last_byte_position_ = size - 1;
64 return true; 64 return true;
65 } 65 }
66 if (first_byte_position_ < size) { 66 if (first_byte_position_ < size) {
67 if (HasLastBytePosition()) 67 if (HasLastBytePosition())
68 last_byte_position_ = std::min(size - 1, last_byte_position_); 68 last_byte_position_ = std::min(size - 1, last_byte_position_);
69 else 69 else
70 last_byte_position_ = size - 1; 70 last_byte_position_ = size - 1;
71 return true; 71 return true;
72 } 72 }
73 return false; 73 return false;
74 } 74 }
75 75
76 } // namespace net 76 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_unittest.cc ('k') | net/http/http_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698