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

Unified Diff: chrome/renderer/resources/extensions/last_error.js

Issue 12632004: Revert 186643 - Caused a 10% regression on SunSpider benchmark (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/last_error.js
===================================================================
--- chrome/renderer/resources/extensions/last_error.js (revision 186747)
+++ chrome/renderer/resources/extensions/last_error.js (working copy)
@@ -2,57 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-var DCHECK = requireNative('logging').DCHECK;
-var GetAvailability = requireNative('v8_context').GetAvailability;
-var GetGlobal = requireNative('sendRequest').GetGlobal;
+requireNative('runtime');
-// Utility for setting chrome.*.lastError.
-//
-// A utility here is useful for two reasons:
-// 1. For backwards compatibility we need to set chrome.extension.lastError,
-// but not all contexts actually have access to the extension namespace.
-// 2. When calling across contexts, the global object that gets lastError set
-// needs to be that of the caller. We force callers to explicitly specify
-// the chrome object to try to prevent bugs here.
-
-/**
- * Sets the last error on |targetChrome| to |message|.
- */
-function set(message, targetChrome) {
- DCHECK(targetChrome != undefined);
- clear(targetChrome); // in case somebody has set a sneaky getter/setter
+function set(message) {
var errorObject = { 'message': message };
- if (GetAvailability('extension').is_available)
- targetChrome.extension.lastError = errorObject;
- targetChrome.runtime.lastError = errorObject;
+ if (chrome.extension)
+ chrome.extension.lastError = errorObject;
+ chrome.runtime.lastError = errorObject;
};
-/**
- * Clears the last error on |targetChrome|.
- */
-function clear(targetChrome) {
- DCHECK(targetChrome != undefined);
- if (GetAvailability('extension').is_available)
- delete targetChrome.extension.lastError;
- delete targetChrome.runtime.lastError;
+function clear() {
+ if (chrome.extension)
+ delete chrome.extension.lastError;
+ delete chrome.runtime.lastError;
};
-/**
- * Runs |callback(args)| with last error set to |message|.
- *
- * The target chrome object is the global object's of the callback, so this
- * method won't work if the real callback has been wrapped (etc).
- */
-function run(message, callback, args) {
- var targetChrome = GetGlobal(callback).chrome;
- set(message, targetChrome);
- try {
- callback.apply(undefined, args);
- } finally {
- clear(targetChrome);
- }
-}
-
exports.clear = clear;
exports.set = set;
-exports.run = run;

Powered by Google App Engine
This is Rietveld 408576698