| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright (C) 2012 Google, Inc. All rights reserved. | 3 * Copyright (C) 2012 Google, Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 if (!context) | 598 if (!context) |
| 599 return; | 599 return; |
| 600 if (context->isDocument()) { | 600 if (context->isDocument()) { |
| 601 count(*toDocument(context), feature); | 601 count(*toDocument(context), feature); |
| 602 return; | 602 return; |
| 603 } | 603 } |
| 604 if (context->isWorkerGlobalScope()) | 604 if (context->isWorkerGlobalScope()) |
| 605 toWorkerGlobalScope(context)->countFeature(feature); | 605 toWorkerGlobalScope(context)->countFeature(feature); |
| 606 } | 606 } |
| 607 | 607 |
| 608 void UseCounter::countIfNotPrivateScript(v8::Isolate* isolate, const Document& d
ocument, Feature feature) |
| 609 { |
| 610 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld()) |
| 611 return; |
| 612 UseCounter::count(document, feature); |
| 613 } |
| 614 |
| 615 void UseCounter::countIfNotPrivateScript(v8::Isolate* isolate, const ExecutionCo
ntext* context, Feature feature) |
| 616 { |
| 617 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld()) |
| 618 return; |
| 619 UseCounter::count(context, feature); |
| 620 } |
| 621 |
| 608 void UseCounter::countDeprecation(ExecutionContext* context, Feature feature) | 622 void UseCounter::countDeprecation(ExecutionContext* context, Feature feature) |
| 609 { | 623 { |
| 610 if (!context) | 624 if (!context) |
| 611 return; | 625 return; |
| 612 if (context->isDocument()) { | 626 if (context->isDocument()) { |
| 613 UseCounter::countDeprecation(*toDocument(context), feature); | 627 UseCounter::countDeprecation(*toDocument(context), feature); |
| 614 return; | 628 return; |
| 615 } | 629 } |
| 616 if (context->isWorkerGlobalScope()) | 630 if (context->isWorkerGlobalScope()) |
| 617 toWorkerGlobalScope(context)->countDeprecation(feature); | 631 toWorkerGlobalScope(context)->countDeprecation(feature); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 630 LocalFrame* frame = document.frame(); | 644 LocalFrame* frame = document.frame(); |
| 631 if (!host || !frame) | 645 if (!host || !frame) |
| 632 return; | 646 return; |
| 633 | 647 |
| 634 if (host->useCounter().recordMeasurement(feature)) { | 648 if (host->useCounter().recordMeasurement(feature)) { |
| 635 ASSERT(!host->useCounter().deprecationMessage(feature).isEmpty()); | 649 ASSERT(!host->useCounter().deprecationMessage(feature).isEmpty()); |
| 636 frame->console().addMessage(ConsoleMessage::create(DeprecationMessageSou
rce, WarningMessageLevel, host->useCounter().deprecationMessage(feature))); | 650 frame->console().addMessage(ConsoleMessage::create(DeprecationMessageSou
rce, WarningMessageLevel, host->useCounter().deprecationMessage(feature))); |
| 637 } | 651 } |
| 638 } | 652 } |
| 639 | 653 |
| 654 void UseCounter::countDeprecationIfNotPrivateScript(v8::Isolate* isolate, Execut
ionContext* context, Feature feature) |
| 655 { |
| 656 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld()) |
| 657 return; |
| 658 UseCounter::countDeprecation(context, feature); |
| 659 } |
| 660 |
| 640 // FIXME: Update other UseCounter::deprecationMessage() cases to use this. | 661 // FIXME: Update other UseCounter::deprecationMessage() cases to use this. |
| 641 static String replacedBy(const char* oldString, const char* newString) | 662 static String replacedBy(const char* oldString, const char* newString) |
| 642 { | 663 { |
| 643 return String::format("'%s' is deprecated. Please use '%s' instead.", oldStr
ing, newString); | 664 return String::format("'%s' is deprecated. Please use '%s' instead.", oldStr
ing, newString); |
| 644 } | 665 } |
| 645 | 666 |
| 646 String UseCounter::deprecationMessage(Feature feature) | 667 String UseCounter::deprecationMessage(Feature feature) |
| 647 { | 668 { |
| 648 switch (feature) { | 669 switch (feature) { |
| 649 // Quota | 670 // Quota |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) | 854 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) |
| 834 { | 855 { |
| 835 // FIXME: We may want to handle stylesheets that have multiple owners | 856 // FIXME: We may want to handle stylesheets that have multiple owners |
| 836 // http://crbug.com/242125 | 857 // http://crbug.com/242125 |
| 837 if (sheetContents && sheetContents->hasSingleOwnerNode()) | 858 if (sheetContents && sheetContents->hasSingleOwnerNode()) |
| 838 return getFrom(sheetContents->singleOwnerDocument()); | 859 return getFrom(sheetContents->singleOwnerDocument()); |
| 839 return 0; | 860 return 0; |
| 840 } | 861 } |
| 841 | 862 |
| 842 } // namespace blink | 863 } // namespace blink |
| OLD | NEW |