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

Side by Side Diff: ppapi/proxy/websocket_resource.cc

Issue 1502503004: Remove kuint64max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint8
Patch Set: rebase Created 5 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ppapi/proxy/websocket_resource.h" 5 #include "ppapi/proxy/websocket_resource.h"
6 6
7 #include <limits>
7 #include <set> 8 #include <set>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/numerics/safe_conversions.h" 13 #include "base/numerics/safe_conversions.h"
13 #include "ppapi/c/pp_errors.h" 14 #include "ppapi/c/pp_errors.h"
14 #include "ppapi/proxy/dispatch_reply_message.h" 15 #include "ppapi/proxy/dispatch_reply_message.h"
15 #include "ppapi/proxy/ppapi_messages.h" 16 #include "ppapi/proxy/ppapi_messages.h"
16 #include "ppapi/shared_impl/ppapi_globals.h" 17 #include "ppapi/shared_impl/ppapi_globals.h"
17 #include "ppapi/shared_impl/var.h" 18 #include "ppapi/shared_impl/var.h"
18 #include "ppapi/shared_impl/var_tracker.h" 19 #include "ppapi/shared_impl/var_tracker.h"
19 20
20 namespace { 21 namespace {
21 22
22 const uint32_t kMaxReasonSizeInBytes = 123; 23 const uint32_t kMaxReasonSizeInBytes = 123;
23 const size_t kBaseFramingOverhead = 2; 24 const size_t kBaseFramingOverhead = 2;
24 const size_t kMaskingKeyLength = 4; 25 const size_t kMaskingKeyLength = 4;
25 const size_t kMinimumPayloadSizeWithTwoByteExtendedPayloadLength = 126; 26 const size_t kMinimumPayloadSizeWithTwoByteExtendedPayloadLength = 126;
26 const size_t kMinimumPayloadSizeWithEightByteExtendedPayloadLength = 0x10000; 27 const size_t kMinimumPayloadSizeWithEightByteExtendedPayloadLength = 0x10000;
27 28
28 uint64_t SaturateAdd(uint64_t a, uint64_t b) { 29 uint64_t SaturateAdd(uint64_t a, uint64_t b) {
29 if (kuint64max - a < b) 30 if (std::numeric_limits<uint64_t>::max() - a < b)
30 return kuint64max; 31 return std::numeric_limits<uint64_t>::max();
31 return a + b; 32 return a + b;
32 } 33 }
33 34
34 uint64_t GetFrameSize(uint64_t payload_size) { 35 uint64_t GetFrameSize(uint64_t payload_size) {
35 uint64_t overhead = kBaseFramingOverhead + kMaskingKeyLength; 36 uint64_t overhead = kBaseFramingOverhead + kMaskingKeyLength;
36 if (payload_size > kMinimumPayloadSizeWithEightByteExtendedPayloadLength) 37 if (payload_size > kMinimumPayloadSizeWithEightByteExtendedPayloadLength)
37 overhead += 8; 38 overhead += 8;
38 else if (payload_size > kMinimumPayloadSizeWithTwoByteExtendedPayloadLength) 39 else if (payload_size > kMinimumPayloadSizeWithTwoByteExtendedPayloadLength)
39 overhead += 2; 40 overhead += 2;
40 return SaturateAdd(payload_size, overhead); 41 return SaturateAdd(payload_size, overhead);
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 return PP_OK; 479 return PP_OK;
479 480
480 *receive_callback_var_ = received_messages_.front()->GetPPVar(); 481 *receive_callback_var_ = received_messages_.front()->GetPPVar();
481 received_messages_.pop(); 482 received_messages_.pop();
482 receive_callback_var_ = NULL; 483 receive_callback_var_ = NULL;
483 return PP_OK; 484 return PP_OK;
484 } 485 }
485 486
486 } // namespace proxy 487 } // namespace proxy
487 } // namespace ppapi 488 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698