public function processRequest()
 {
     $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $this->phid);
     if (!$file) {
         return new Aphront404Response();
     }
     $data = $file->loadFileData();
     $data = unserialize($data);
     if (!$data) {
         throw new Exception("Failed to unserialize XHProf profile!");
     }
     $request = $this->getRequest();
     $symbol = $request->getStr('symbol');
     $is_framed = $request->getBool('frame');
     if ($symbol) {
         $view = new PhabricatorXHProfProfileSymbolView();
         $view->setSymbol($symbol);
     } else {
         $view = new PhabricatorXHProfProfileTopLevelView();
         $view->setLimit(100);
     }
     $view->setBaseURI($request->getRequestURI()->getPath());
     $view->setIsFramed($is_framed);
     $view->setProfileData($data);
     return $this->buildStandardPageResponse($view, array('title' => 'Profile', 'frame' => $is_framed));
 }
 public function handleRequest(AphrontRequest $request)
 {
     $phid = $request->getURIData('phid');
     $file = id(new PhabricatorFileQuery())->setViewer($request->getUser())->withPHIDs(array($phid))->executeOne();
     if (!$file) {
         return new Aphront404Response();
     }
     $data = $file->loadFileData();
     try {
         $data = phutil_json_decode($data);
     } catch (PhutilJSONParserException $ex) {
         throw new PhutilProxyException(pht('Failed to unserialize XHProf profile!'), $ex);
     }
     $symbol = $request->getStr('symbol');
     $is_framed = $request->getBool('frame');
     if ($symbol) {
         $view = new PhabricatorXHProfProfileSymbolView();
         $view->setSymbol($symbol);
     } else {
         $view = new PhabricatorXHProfProfileTopLevelView();
         $view->setFile($file);
         $view->setLimit(100);
     }
     $view->setBaseURI($request->getRequestURI()->getPath());
     $view->setIsFramed($is_framed);
     $view->setProfileData($data);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('%s Profile', $symbol));
     return $this->buildStandardPageResponse(array($crumbs, $view), array('title' => pht('Profile'), 'frame' => $is_framed));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $file = id(new PhabricatorFileQuery())->setViewer($request->getUser())->withPHIDs(array($this->phid))->executeOne();
     if (!$file) {
         return new Aphront404Response();
     }
     $data = $file->loadFileData();
     $data = @json_decode($data, true);
     if (!$data) {
         throw new Exception('Failed to unserialize XHProf profile!');
     }
     $symbol = $request->getStr('symbol');
     $is_framed = $request->getBool('frame');
     if ($symbol) {
         $view = new PhabricatorXHProfProfileSymbolView();
         $view->setSymbol($symbol);
     } else {
         $view = new PhabricatorXHProfProfileTopLevelView();
         $view->setFile($file);
         $view->setLimit(100);
     }
     $view->setBaseURI($request->getRequestURI()->getPath());
     $view->setIsFramed($is_framed);
     $view->setProfileData($data);
     return $this->buildStandardPageResponse($view, array('title' => 'Profile', 'frame' => $is_framed));
 }