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

Side by Side Diff: third_party/WebKit/Source/core/loader/PingLoader.cpp

Issue 2751953002: sendBeacon(): once transmission allowance has been reached, always fail. (Closed)
Patch Set: fix test description imprecision Created 3 years, 9 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 | « third_party/WebKit/LayoutTests/http/tests/sendbeacon/beacon-allowance-limit.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/sendbeacon/beacon-allowance-limit.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698