mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Fix iframe issue for XHProf DarkConsole plugin
Summary: While sort of gross, this seems fairly reasonable overall? I guess? (This patch clearly does more good than harm, although it could just do the good without the harm.) Test Plan: Clicked XHProf links from the frame and from the /xhprof/ tool. Reviewers: btrahan, aran, jungejason, ide Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T453 Differential Revision: https://secure.phabricator.com/D1498
This commit is contained in:
parent
7d46e02631
commit
76dac260e7
8 changed files with 80 additions and 54 deletions
|
@ -778,6 +778,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorXHProfProfileController' => 'applications/xhprof/controller/profile',
|
'PhabricatorXHProfProfileController' => 'applications/xhprof/controller/profile',
|
||||||
'PhabricatorXHProfProfileSymbolView' => 'applications/xhprof/view/symbol',
|
'PhabricatorXHProfProfileSymbolView' => 'applications/xhprof/view/symbol',
|
||||||
'PhabricatorXHProfProfileTopLevelView' => 'applications/xhprof/view/toplevel',
|
'PhabricatorXHProfProfileTopLevelView' => 'applications/xhprof/view/toplevel',
|
||||||
|
'PhabricatorXHProfProfileView' => 'applications/xhprof/view/base',
|
||||||
'PhrictionActionConstants' => 'applications/phriction/constants/action',
|
'PhrictionActionConstants' => 'applications/phriction/constants/action',
|
||||||
'PhrictionChangeType' => 'applications/phriction/constants/changetype',
|
'PhrictionChangeType' => 'applications/phriction/constants/changetype',
|
||||||
'PhrictionConstants' => 'applications/phriction/constants/base',
|
'PhrictionConstants' => 'applications/phriction/constants/base',
|
||||||
|
@ -1448,8 +1449,9 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorXHPASTViewTreeController' => 'PhabricatorXHPASTViewPanelController',
|
'PhabricatorXHPASTViewTreeController' => 'PhabricatorXHPASTViewPanelController',
|
||||||
'PhabricatorXHProfController' => 'PhabricatorController',
|
'PhabricatorXHProfController' => 'PhabricatorController',
|
||||||
'PhabricatorXHProfProfileController' => 'PhabricatorXHProfController',
|
'PhabricatorXHProfProfileController' => 'PhabricatorXHProfController',
|
||||||
'PhabricatorXHProfProfileSymbolView' => 'AphrontView',
|
'PhabricatorXHProfProfileSymbolView' => 'PhabricatorXHProfProfileView',
|
||||||
'PhabricatorXHProfProfileTopLevelView' => 'AphrontView',
|
'PhabricatorXHProfProfileTopLevelView' => 'PhabricatorXHProfProfileView',
|
||||||
|
'PhabricatorXHProfProfileView' => 'AphrontView',
|
||||||
'PhrictionActionConstants' => 'PhrictionConstants',
|
'PhrictionActionConstants' => 'PhrictionConstants',
|
||||||
'PhrictionChangeType' => 'PhrictionConstants',
|
'PhrictionChangeType' => 'PhrictionConstants',
|
||||||
'PhrictionContent' => 'PhrictionDAO',
|
'PhrictionContent' => 'PhrictionDAO',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 Facebook, Inc.
|
* Copyright 2012 Facebook, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -44,21 +44,25 @@ class PhabricatorXHProfProfileController
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$symbol = $request->getStr('symbol');
|
$symbol = $request->getStr('symbol');
|
||||||
|
|
||||||
|
$is_framed = $request->getBool('frame');
|
||||||
|
|
||||||
if ($symbol) {
|
if ($symbol) {
|
||||||
$view = new PhabricatorXHProfProfileSymbolView();
|
$view = new PhabricatorXHProfProfileSymbolView();
|
||||||
$view->setProfileData($data);
|
|
||||||
$view->setSymbol($symbol);
|
$view->setSymbol($symbol);
|
||||||
} else {
|
} else {
|
||||||
$view = new PhabricatorXHProfProfileTopLevelView();
|
$view = new PhabricatorXHProfProfileTopLevelView();
|
||||||
$view->setProfileData($data);
|
|
||||||
$view->setLimit(100);
|
$view->setLimit(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$view->setBaseURI($request->getRequestURI()->getPath());
|
||||||
|
$view->setIsFramed($is_framed);
|
||||||
|
$view->setProfileData($data);
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
||||||
$view,
|
$view,
|
||||||
array(
|
array(
|
||||||
'title' => 'Profile',
|
'title' => 'Profile',
|
||||||
'frame' => $request->getBool('frame'),
|
'frame' => $is_framed,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2012 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
abstract class PhabricatorXHProfProfileView extends AphrontView {
|
||||||
|
|
||||||
|
private $baseURI;
|
||||||
|
private $isFramed;
|
||||||
|
|
||||||
|
public function setIsFramed($is_framed) {
|
||||||
|
$this->isFramed = $is_framed;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBaseURI($uri) {
|
||||||
|
$this->baseURI = $uri;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function renderSymbolLink($symbol) {
|
||||||
|
return phutil_render_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => $this->baseURI.'?symbol='.$symbol,
|
||||||
|
'target' => $this->isFramed ? '_top' : null,
|
||||||
|
),
|
||||||
|
phutil_escape_html($symbol));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
14
src/applications/xhprof/view/base/__init__.php
Normal file
14
src/applications/xhprof/view/base/__init__.php
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'view/base');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorXHProfProfileView.php');
|
|
@ -19,10 +19,10 @@
|
||||||
/**
|
/**
|
||||||
* @phutil-external-symbol function xhprof_compute_flat_info
|
* @phutil-external-symbol function xhprof_compute_flat_info
|
||||||
*/
|
*/
|
||||||
class PhabricatorXHProfProfileSymbolView extends AphrontView {
|
final class PhabricatorXHProfProfileSymbolView
|
||||||
|
extends PhabricatorXHProfProfileView {
|
||||||
|
|
||||||
private $profileData;
|
private $profileData;
|
||||||
private $baseURI;
|
|
||||||
private $symbol;
|
private $symbol;
|
||||||
|
|
||||||
public function setProfileData(array $data) {
|
public function setProfileData(array $data) {
|
||||||
|
@ -30,11 +30,6 @@ class PhabricatorXHProfProfileSymbolView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBaseURI($uri) {
|
|
||||||
$this->baseURI = $uri;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setSymbol($symbol) {
|
public function setSymbol($symbol) {
|
||||||
$this->symbol = $symbol;
|
$this->symbol = $symbol;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -67,8 +62,6 @@ class PhabricatorXHProfProfileSymbolView extends AphrontView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$base_uri = $this->baseURI;
|
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
'Metrics for this Call',
|
'Metrics for this Call',
|
||||||
|
@ -77,12 +70,7 @@ class PhabricatorXHProfProfileSymbolView extends AphrontView {
|
||||||
'',
|
'',
|
||||||
);
|
);
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
phutil_render_tag(
|
$this->renderSymbolLink($symbol),
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => $base_uri.'?symbol='.$symbol,
|
|
||||||
),
|
|
||||||
phutil_escape_html($symbol)),
|
|
||||||
$flat[$symbol]['ct'],
|
$flat[$symbol]['ct'],
|
||||||
$flat[$symbol]['wt'],
|
$flat[$symbol]['wt'],
|
||||||
'100%',
|
'100%',
|
||||||
|
@ -96,12 +84,7 @@ class PhabricatorXHProfProfileSymbolView extends AphrontView {
|
||||||
);
|
);
|
||||||
foreach ($parents as $key => $name) {
|
foreach ($parents as $key => $name) {
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
phutil_render_tag(
|
$this->renderSymbolLink($name),
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => $base_uri.'?symbol='.$name,
|
|
||||||
),
|
|
||||||
phutil_escape_html($name)),
|
|
||||||
$data[$key]['ct'],
|
$data[$key]['ct'],
|
||||||
$data[$key]['wt'],
|
$data[$key]['wt'],
|
||||||
'',
|
'',
|
||||||
|
@ -152,17 +135,10 @@ class PhabricatorXHProfProfileSymbolView extends AphrontView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function formatRows($rows) {
|
private function formatRows($rows) {
|
||||||
$base_uri = $this->baseURI;
|
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$result[] = array(
|
$result[] = array(
|
||||||
phutil_render_tag(
|
$this->renderSymbolLink($row[0]),
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => $base_uri.'?symbol='.$row[0],
|
|
||||||
),
|
|
||||||
phutil_escape_html($row[0])),
|
|
||||||
number_format($row[1]),
|
number_format($row[1]),
|
||||||
number_format($row[2]).' us',
|
number_format($row[2]).' us',
|
||||||
sprintf('%.1f%%', 100 * $row[3]),
|
sprintf('%.1f%%', 100 * $row[3]),
|
||||||
|
|
|
@ -7,11 +7,10 @@
|
||||||
|
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'aphront/console/plugin/xhprof/api');
|
phutil_require_module('phabricator', 'aphront/console/plugin/xhprof/api');
|
||||||
phutil_require_module('phabricator', 'view/base');
|
phutil_require_module('phabricator', 'applications/xhprof/view/base');
|
||||||
phutil_require_module('phabricator', 'view/control/table');
|
phutil_require_module('phabricator', 'view/control/table');
|
||||||
phutil_require_module('phabricator', 'view/layout/panel');
|
phutil_require_module('phabricator', 'view/layout/panel');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'markup');
|
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
/**
|
/**
|
||||||
* @phutil-external-symbol function xhprof_compute_flat_info
|
* @phutil-external-symbol function xhprof_compute_flat_info
|
||||||
*/
|
*/
|
||||||
class PhabricatorXHProfProfileTopLevelView extends AphrontView {
|
final class PhabricatorXHProfProfileTopLevelView
|
||||||
|
extends PhabricatorXHProfProfileView {
|
||||||
|
|
||||||
private $profileData;
|
private $profileData;
|
||||||
private $limit;
|
private $limit;
|
||||||
private $baseURI;
|
|
||||||
|
|
||||||
public function setProfileData(array $data) {
|
public function setProfileData(array $data) {
|
||||||
$this->profileData = $data;
|
$this->profileData = $data;
|
||||||
|
@ -35,11 +35,6 @@ class PhabricatorXHProfProfileTopLevelView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBaseURI($uri) {
|
|
||||||
$this->baseURI = $uri;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
DarkConsoleXHProfPluginAPI::includeXHProfLib();
|
DarkConsoleXHProfPluginAPI::includeXHProfLib();
|
||||||
|
|
||||||
|
@ -81,16 +76,9 @@ class PhabricatorXHProfProfileTopLevelView extends AphrontView {
|
||||||
$flat = array_slice($flat, 0, $this->limit);
|
$flat = array_slice($flat, 0, $this->limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
$base_uri = $this->baseURI;
|
|
||||||
|
|
||||||
foreach ($flat as $call => $counters) {
|
foreach ($flat as $call => $counters) {
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
phutil_render_tag(
|
$this->renderSymbolLink($call),
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => $base_uri.'?symbol='.$call,
|
|
||||||
),
|
|
||||||
phutil_escape_html($call)),
|
|
||||||
number_format($counters['ct']),
|
number_format($counters['ct']),
|
||||||
number_format($counters['wt']).' us',
|
number_format($counters['wt']).' us',
|
||||||
sprintf('%.1f%%', 100 * $counters['wt'] / $totals['wt']),
|
sprintf('%.1f%%', 100 * $counters['wt'] / $totals['wt']),
|
||||||
|
|
|
@ -7,11 +7,10 @@
|
||||||
|
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'aphront/console/plugin/xhprof/api');
|
phutil_require_module('phabricator', 'aphront/console/plugin/xhprof/api');
|
||||||
phutil_require_module('phabricator', 'view/base');
|
phutil_require_module('phabricator', 'applications/xhprof/view/base');
|
||||||
phutil_require_module('phabricator', 'view/control/table');
|
phutil_require_module('phabricator', 'view/control/table');
|
||||||
phutil_require_module('phabricator', 'view/layout/panel');
|
phutil_require_module('phabricator', 'view/layout/panel');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'markup');
|
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue