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

Unified Diff: chrome/renderer/loadtimes_extension_bindings.cc

Issue 2149933003: Pre-work for adding usage counter for chrome.loadtimes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/loadtimes_extension_bindings.cc
diff --git a/chrome/renderer/loadtimes_extension_bindings.cc b/chrome/renderer/loadtimes_extension_bindings.cc
index a1aad263c03b96d47762d65ffce72580ab480ea0..c45acaa9a4357730b387dc5838c9bb098c178b4c 100644
--- a/chrome/renderer/loadtimes_extension_bindings.cc
+++ b/chrome/renderer/loadtimes_extension_bindings.cc
@@ -8,6 +8,7 @@
#include "base/time/time.h"
#include "content/public/renderer/document_state.h"
+#include "extensions/renderer/v8_helpers.h"
#include "net/http/http_response_info.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebPerformance.h"
@@ -105,6 +106,13 @@ class LoadTimesExtensionWrapper : public v8::Extension {
return kTransitionOther;
}
+ static void TestLoadtimesGetter(
+ v8::Local<v8::Name> name,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ v8::Local<v8::Object> param = v8::Local<v8::Object>::Cast(info.Data());
adamk 2016/07/14 22:09:03 Object here is the wrong type (since you might hav
+ info.GetReturnValue().Set(param);
+ }
+
static void GetLoadTimes(const v8::FunctionCallbackInfo<v8::Value>& args) {
args.GetReturnValue().SetNull();
WebLocalFrame* frame = WebLocalFrame::frameForCurrentContext();
@@ -170,11 +178,15 @@ class LoadTimesExtensionWrapper : public v8::Extension {
v8::Isolate* isolate = args.GetIsolate();
v8::Local<v8::Context> ctx = isolate->GetCurrentContext();
v8::Local<v8::Object> load_times = v8::Object::New(isolate);
+
if (!load_times
- ->Set(ctx, v8::String::NewFromUtf8(isolate, "requestTime",
- v8::NewStringType::kNormal)
- .ToLocalChecked(),
- v8::Number::New(isolate, request_time))
+ ->SetAccessor(
+ ctx,
+ extensions::v8_helpers::ToV8StringUnsafe(
+ isolate, "requestTime", v8::NewStringType::kNormal),
+ TestLoadtimesGetter,
+ nullptr,
+ v8::Number::New(isolate, request_time))
.FromMaybe(false)) {
return;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698