get webContentsId instead
This commit is contained in:
parent
13d363d1f1
commit
2d771674bb
3 changed files with 12 additions and 10 deletions
|
@ -30,15 +30,15 @@ class TrackableObjectBase {
|
||||||
// Wrap TrackableObject into a class that SupportsUserData.
|
// Wrap TrackableObject into a class that SupportsUserData.
|
||||||
void AttachAsUserData(base::SupportsUserData* wrapped);
|
void AttachAsUserData(base::SupportsUserData* wrapped);
|
||||||
|
|
||||||
|
// Get the weak_map_id from SupportsUserData.
|
||||||
|
static int32_t GetIDFromWrappedClass(base::SupportsUserData* wrapped);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~TrackableObjectBase();
|
virtual ~TrackableObjectBase();
|
||||||
|
|
||||||
// Returns a closure that can destroy the native class.
|
// Returns a closure that can destroy the native class.
|
||||||
base::Closure GetDestroyClosure();
|
base::Closure GetDestroyClosure();
|
||||||
|
|
||||||
// Get the weak_map_id from SupportsUserData.
|
|
||||||
static int32_t GetIDFromWrappedClass(base::SupportsUserData* wrapped);
|
|
||||||
|
|
||||||
// Register a callback that should be destroyed before JavaScript environment
|
// Register a callback that should be destroyed before JavaScript environment
|
||||||
// gets destroyed.
|
// gets destroyed.
|
||||||
static base::Closure RegisterDestructionCallback(const base::Closure& c);
|
static base::Closure RegisterDestructionCallback(const base::Closure& c);
|
||||||
|
|
|
@ -6,11 +6,13 @@
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "atom/browser/api/atom_api_web_contents.h"
|
||||||
#include "atom/common/native_mate_converters/net_converter.h"
|
#include "atom/common/native_mate_converters/net_converter.h"
|
||||||
#include "base/stl_util.h"
|
#include "base/stl_util.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "brightray/browser/net/devtools_network_transaction.h"
|
#include "brightray/browser/net/devtools_network_transaction.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
|
#include "content/public/browser/render_frame_host.h"
|
||||||
#include "net/url_request/url_request.h"
|
#include "net/url_request/url_request.h"
|
||||||
|
|
||||||
using brightray::DevToolsNetworkTransaction;
|
using brightray::DevToolsNetworkTransaction;
|
||||||
|
@ -74,13 +76,13 @@ void ToDictionary(base::DictionaryValue* details, net::URLRequest* request) {
|
||||||
FillRequestDetails(details, request);
|
FillRequestDetails(details, request);
|
||||||
details->SetInteger("id", request->identifier());
|
details->SetInteger("id", request->identifier());
|
||||||
details->SetDouble("timestamp", base::Time::Now().ToDoubleT() * 1000);
|
details->SetDouble("timestamp", base::Time::Now().ToDoubleT() * 1000);
|
||||||
auto info = content::ResourceRequestInfo::ForRequest(request);
|
const content::ResourceRequestInfo* info = content::ResourceRequestInfo::ForRequest(request);
|
||||||
if (info) {
|
if (info) {
|
||||||
int64_t process_id = info->GetChildID();
|
int process_id = info->GetChildID();
|
||||||
int64_t routing_id = info->GetRouteID();
|
int frame_id = info->GetRenderFrameID();
|
||||||
details->SetDouble("webContentsGetId", (process_id << 32) + routing_id);
|
content::WebContents* webContents
|
||||||
details->SetString("resourceType",
|
= content::WebContents::FromRenderFrameHost(content::RenderFrameHost::FromID(process_id, frame_id));
|
||||||
ResourceTypeToString(info->GetResourceType()));
|
details->SetInteger("webContentsId", atom::api::WebContents::GetIDFromWrappedClass(webContents));
|
||||||
} else {
|
} else {
|
||||||
details->SetString("resourceType", "other");
|
details->SetString("resourceType", "other");
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ describe('webRequest module', function () {
|
||||||
ses.webRequest.onBeforeRequest(function (details, callback) {
|
ses.webRequest.onBeforeRequest(function (details, callback) {
|
||||||
assert.equal(typeof details.id, 'number')
|
assert.equal(typeof details.id, 'number')
|
||||||
assert.equal(typeof details.timestamp, 'number')
|
assert.equal(typeof details.timestamp, 'number')
|
||||||
assert.equal(typeof details.webContentsGetId, 'number')
|
assert.equal(typeof details.webContentsId, 'number')
|
||||||
assert.equal(details.url, defaultURL)
|
assert.equal(details.url, defaultURL)
|
||||||
assert.equal(details.method, 'GET')
|
assert.equal(details.method, 'GET')
|
||||||
assert.equal(details.resourceType, 'xhr')
|
assert.equal(details.resourceType, 'xhr')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue