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

Side by Side Diff: chrome/browser/extensions/api/processes/processes_api.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/processes/processes_api.h" 5 #include "chrome/browser/extensions/api/processes/processes_api.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // This does not include memory. The memory refresh flag will only be added once 49 // This does not include memory. The memory refresh flag will only be added once
50 // a listener to OnUpdatedWithMemory event is added. 50 // a listener to OnUpdatedWithMemory event is added.
51 int64_t GetRefreshTypesForProcessOptionalData() { 51 int64_t GetRefreshTypesForProcessOptionalData() {
52 return task_management::REFRESH_TYPE_CPU | 52 return task_management::REFRESH_TYPE_CPU |
53 task_management::REFRESH_TYPE_NETWORK_USAGE | 53 task_management::REFRESH_TYPE_NETWORK_USAGE |
54 task_management::REFRESH_TYPE_SQLITE_MEMORY | 54 task_management::REFRESH_TYPE_SQLITE_MEMORY |
55 task_management::REFRESH_TYPE_V8_MEMORY | 55 task_management::REFRESH_TYPE_V8_MEMORY |
56 task_management::REFRESH_TYPE_WEBCACHE_STATS; 56 task_management::REFRESH_TYPE_WEBCACHE_STATS;
57 } 57 }
58 58
59 scoped_ptr<api::processes::Cache> CreateCacheData( 59 std::unique_ptr<api::processes::Cache> CreateCacheData(
60 const blink::WebCache::ResourceTypeStat& stat) { 60 const blink::WebCache::ResourceTypeStat& stat) {
61 scoped_ptr<api::processes::Cache> cache(new api::processes::Cache()); 61 std::unique_ptr<api::processes::Cache> cache(new api::processes::Cache());
62 cache->size = static_cast<double>(stat.size); 62 cache->size = static_cast<double>(stat.size);
63 cache->live_size = static_cast<double>(stat.liveSize); 63 cache->live_size = static_cast<double>(stat.liveSize);
64 return cache; 64 return cache;
65 } 65 }
66 66
67 api::processes::ProcessType GetProcessType( 67 api::processes::ProcessType GetProcessType(
68 task_management::Task::Type task_type) { 68 task_management::Task::Type task_type) {
69 switch (task_type) { 69 switch (task_type) {
70 case task_management::Task::BROWSER: 70 case task_management::Task::BROWSER:
71 return api::processes::PROCESS_TYPE_BROWSER; 71 return api::processes::PROCESS_TYPE_BROWSER;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 false, // include_optional 318 false, // include_optional
319 &process); 319 &process);
320 DispatchEvent(events::PROCESSES_ON_UNRESPONSIVE, 320 DispatchEvent(events::PROCESSES_ON_UNRESPONSIVE,
321 api::processes::OnUnresponsive::kEventName, 321 api::processes::OnUnresponsive::kEventName,
322 api::processes::OnUnresponsive::Create(process)); 322 api::processes::OnUnresponsive::Create(process));
323 } 323 }
324 324
325 void ProcessesEventRouter::DispatchEvent( 325 void ProcessesEventRouter::DispatchEvent(
326 events::HistogramValue histogram_value, 326 events::HistogramValue histogram_value,
327 const std::string& event_name, 327 const std::string& event_name,
328 scoped_ptr<base::ListValue> event_args) const { 328 std::unique_ptr<base::ListValue> event_args) const {
329 EventRouter* event_router = EventRouter::Get(browser_context_); 329 EventRouter* event_router = EventRouter::Get(browser_context_);
330 if (event_router) { 330 if (event_router) {
331 scoped_ptr<Event> event( 331 std::unique_ptr<Event> event(
332 new Event(histogram_value, event_name, std::move(event_args))); 332 new Event(histogram_value, event_name, std::move(event_args)));
333 event_router->BroadcastEvent(std::move(event)); 333 event_router->BroadcastEvent(std::move(event));
334 } 334 }
335 } 335 }
336 336
337 bool ProcessesEventRouter::HasEventListeners( 337 bool ProcessesEventRouter::HasEventListeners(
338 const std::string& event_name) const { 338 const std::string& event_name) const {
339 EventRouter* event_router = EventRouter::Get(browser_context_); 339 EventRouter* event_router = EventRouter::Get(browser_context_);
340 return event_router && event_router->HasEventListener(event_name); 340 return event_router && event_router->HasEventListener(event_name);
341 } 341 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 processes_event_router_.reset(new ProcessesEventRouter(browser_context_)); 433 processes_event_router_.reset(new ProcessesEventRouter(browser_context_));
434 return processes_event_router_.get(); 434 return processes_event_router_.get();
435 } 435 }
436 436
437 //////////////////////////////////////////////////////////////////////////////// 437 ////////////////////////////////////////////////////////////////////////////////
438 // ProcessesGetProcessIdForTabFunction: 438 // ProcessesGetProcessIdForTabFunction:
439 //////////////////////////////////////////////////////////////////////////////// 439 ////////////////////////////////////////////////////////////////////////////////
440 440
441 ExtensionFunction::ResponseAction ProcessesGetProcessIdForTabFunction::Run() { 441 ExtensionFunction::ResponseAction ProcessesGetProcessIdForTabFunction::Run() {
442 // For this function, the task manager doesn't even need to be running. 442 // For this function, the task manager doesn't even need to be running.
443 scoped_ptr<api::processes::GetProcessIdForTab::Params> params( 443 std::unique_ptr<api::processes::GetProcessIdForTab::Params> params(
444 api::processes::GetProcessIdForTab::Params::Create(*args_)); 444 api::processes::GetProcessIdForTab::Params::Create(*args_));
445 EXTENSION_FUNCTION_VALIDATE(params.get()); 445 EXTENSION_FUNCTION_VALIDATE(params.get());
446 446
447 const int tab_id = params->tab_id; 447 const int tab_id = params->tab_id;
448 content::WebContents* contents = nullptr; 448 content::WebContents* contents = nullptr;
449 int tab_index = -1; 449 int tab_index = -1;
450 if (!ExtensionTabUtil::GetTabById( 450 if (!ExtensionTabUtil::GetTabById(
451 tab_id, 451 tab_id,
452 Profile::FromBrowserContext(browser_context()), 452 Profile::FromBrowserContext(browser_context()),
453 include_incognito(), 453 include_incognito(),
(...skipping 11 matching lines...) Expand all
465 } 465 }
466 466
467 //////////////////////////////////////////////////////////////////////////////// 467 ////////////////////////////////////////////////////////////////////////////////
468 // ProcessesTerminateFunction: 468 // ProcessesTerminateFunction:
469 //////////////////////////////////////////////////////////////////////////////// 469 ////////////////////////////////////////////////////////////////////////////////
470 470
471 ExtensionFunction::ResponseAction ProcessesTerminateFunction::Run() { 471 ExtensionFunction::ResponseAction ProcessesTerminateFunction::Run() {
472 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 472 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
473 473
474 // For this function, the task manager doesn't even need to be running. 474 // For this function, the task manager doesn't even need to be running.
475 scoped_ptr<api::processes::Terminate::Params> params( 475 std::unique_ptr<api::processes::Terminate::Params> params(
476 api::processes::Terminate::Params::Create(*args_)); 476 api::processes::Terminate::Params::Create(*args_));
477 EXTENSION_FUNCTION_VALIDATE(params.get()); 477 EXTENSION_FUNCTION_VALIDATE(params.get());
478 478
479 child_process_host_id_ = params->process_id; 479 child_process_host_id_ = params->process_id;
480 if (child_process_host_id_ < 0) { 480 if (child_process_host_id_ < 0) {
481 return RespondNow(Error(errors::kInvalidArgument, 481 return RespondNow(Error(errors::kInvalidArgument,
482 base::IntToString(child_process_host_id_))); 482 base::IntToString(child_process_host_id_)));
483 } else if (child_process_host_id_ == 0) { 483 } else if (child_process_host_id_ == 0) {
484 // Cannot kill the browser process. 484 // Cannot kill the browser process.
485 return RespondNow(Error(errors::kNotAllowedToTerminate, 485 return RespondNow(Error(errors::kNotAllowedToTerminate,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 // ProcessesGetProcessInfoFunction: 557 // ProcessesGetProcessInfoFunction:
558 //////////////////////////////////////////////////////////////////////////////// 558 ////////////////////////////////////////////////////////////////////////////////
559 559
560 ProcessesGetProcessInfoFunction::ProcessesGetProcessInfoFunction() 560 ProcessesGetProcessInfoFunction::ProcessesGetProcessInfoFunction()
561 : task_management::TaskManagerObserver( 561 : task_management::TaskManagerObserver(
562 base::TimeDelta::FromSeconds(1), 562 base::TimeDelta::FromSeconds(1),
563 GetRefreshTypesFlagOnlyEssentialData()) { 563 GetRefreshTypesFlagOnlyEssentialData()) {
564 } 564 }
565 565
566 ExtensionFunction::ResponseAction ProcessesGetProcessInfoFunction::Run() { 566 ExtensionFunction::ResponseAction ProcessesGetProcessInfoFunction::Run() {
567 scoped_ptr<api::processes::GetProcessInfo::Params> params( 567 std::unique_ptr<api::processes::GetProcessInfo::Params> params(
568 api::processes::GetProcessInfo::Params::Create(*args_)); 568 api::processes::GetProcessInfo::Params::Create(*args_));
569 EXTENSION_FUNCTION_VALIDATE(params.get()); 569 EXTENSION_FUNCTION_VALIDATE(params.get());
570 if (params->process_ids.as_integer) 570 if (params->process_ids.as_integer)
571 process_host_ids_.push_back(*params->process_ids.as_integer); 571 process_host_ids_.push_back(*params->process_ids.as_integer);
572 else 572 else
573 process_host_ids_.swap(*params->process_ids.as_integers); 573 process_host_ids_.swap(*params->process_ids.as_integers);
574 574
575 include_memory_ = params->include_memory; 575 include_memory_ = params->include_memory;
576 if (include_memory_) 576 if (include_memory_)
577 AddRefreshType(task_management::REFRESH_TYPE_MEMORY); 577 AddRefreshType(task_management::REFRESH_TYPE_MEMORY);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 // Send the response. 680 // Send the response.
681 Respond(ArgumentList( 681 Respond(ArgumentList(
682 api::processes::GetProcessInfo::Results::Create(processes))); 682 api::processes::GetProcessInfo::Results::Create(processes)));
683 683
684 // Stop observing the task manager, and balance the AddRef() in Run(). 684 // Stop observing the task manager, and balance the AddRef() in Run().
685 task_management::TaskManagerInterface::GetTaskManager()->RemoveObserver(this); 685 task_management::TaskManagerInterface::GetTaskManager()->RemoveObserver(this);
686 Release(); 686 Release();
687 } 687 }
688 688
689 } // namespace extensions 689 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/processes/processes_api.h ('k') | chrome/browser/extensions/api/proxy/proxy_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698