OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 419 |
420 bool sendBeaconCommon(LocalFrame* frame, | 420 bool sendBeaconCommon(LocalFrame* frame, |
421 int allowance, | 421 int allowance, |
422 const KURL& url, | 422 const KURL& url, |
423 const Beacon& beacon, | 423 const Beacon& beacon, |
424 int& payloadLength) { | 424 int& payloadLength) { |
425 if (!frame->document()) | 425 if (!frame->document()) |
426 return false; | 426 return false; |
427 | 427 |
428 unsigned long long entitySize = beacon.size(); | 428 unsigned long long entitySize = beacon.size(); |
429 if (allowance > 0 && static_cast<unsigned long long>(allowance) < entitySize) | 429 if (allowance < 0 || static_cast<unsigned long long>(allowance) < entitySize) |
430 return false; | 430 return false; |
431 | 431 |
432 payloadLength = entitySize; | 432 payloadLength = entitySize; |
433 | 433 |
434 ResourceRequest request(url); | 434 ResourceRequest request(url); |
435 request.setHTTPMethod(HTTPNames::POST); | 435 request.setHTTPMethod(HTTPNames::POST); |
436 request.setHTTPHeaderField(HTTPNames::Cache_Control, "max-age=0"); | 436 request.setHTTPHeaderField(HTTPNames::Cache_Control, "max-age=0"); |
437 finishPingRequestInitialization(request, frame, | 437 finishPingRequestInitialization(request, frame, |
438 WebURLRequest::RequestContextBeacon); | 438 WebURLRequest::RequestContextBeacon); |
439 | 439 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 bool PingLoader::sendBeacon(LocalFrame* frame, | 557 bool PingLoader::sendBeacon(LocalFrame* frame, |
558 int allowance, | 558 int allowance, |
559 const KURL& beaconURL, | 559 const KURL& beaconURL, |
560 Blob* data, | 560 Blob* data, |
561 int& payloadLength) { | 561 int& payloadLength) { |
562 BeaconBlob beacon(data); | 562 BeaconBlob beacon(data); |
563 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength); | 563 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength); |
564 } | 564 } |
565 | 565 |
566 } // namespace blink | 566 } // namespace blink |
OLD | NEW |