OLD | NEW |
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/extension_processes_api.h" | 5 #include "chrome/browser/extensions/extension_processes_api.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 } | 561 } |
562 | 562 |
563 void GetProcessIdForTabFunction::GetProcessIdForTab() { | 563 void GetProcessIdForTabFunction::GetProcessIdForTab() { |
564 TabContents* contents = NULL; | 564 TabContents* contents = NULL; |
565 int tab_index = -1; | 565 int tab_index = -1; |
566 if (!ExtensionTabUtil::GetTabById(tab_id_, profile(), include_incognito(), | 566 if (!ExtensionTabUtil::GetTabById(tab_id_, profile(), include_incognito(), |
567 NULL, NULL, &contents, &tab_index)) { | 567 NULL, NULL, &contents, &tab_index)) { |
568 error_ = ExtensionErrorUtils::FormatErrorMessage( | 568 error_ = ExtensionErrorUtils::FormatErrorMessage( |
569 extensions::tabs_constants::kTabNotFoundError, | 569 extensions::tabs_constants::kTabNotFoundError, |
570 base::IntToString(tab_id_)); | 570 base::IntToString(tab_id_)); |
571 result_.reset(Value::CreateIntegerValue(-1)); | 571 SetResult(Value::CreateIntegerValue(-1)); |
572 SendResponse(false); | 572 SendResponse(false); |
573 } else { | 573 } else { |
574 int process_id = contents->web_contents()->GetRenderProcessHost()->GetID(); | 574 int process_id = contents->web_contents()->GetRenderProcessHost()->GetID(); |
575 result_.reset(Value::CreateIntegerValue(process_id)); | 575 SetResult(Value::CreateIntegerValue(process_id)); |
576 SendResponse(true); | 576 SendResponse(true); |
577 } | 577 } |
578 | 578 |
579 // Balance the AddRef in the RunImpl. | 579 // Balance the AddRef in the RunImpl. |
580 Release(); | 580 Release(); |
581 } | 581 } |
582 | 582 |
583 bool TerminateFunction::RunImpl() { | 583 bool TerminateFunction::RunImpl() { |
584 #if defined(ENABLE_TASK_MANAGER) | 584 #if defined(ENABLE_TASK_MANAGER) |
585 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &process_id_)); | 585 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &process_id_)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 break; | 637 break; |
638 } | 638 } |
639 } | 639 } |
640 } | 640 } |
641 | 641 |
642 if (!found) { | 642 if (!found) { |
643 error_ = ExtensionErrorUtils::FormatErrorMessage(errors::kProcessNotFound, | 643 error_ = ExtensionErrorUtils::FormatErrorMessage(errors::kProcessNotFound, |
644 base::IntToString(process_id_)); | 644 base::IntToString(process_id_)); |
645 SendResponse(false); | 645 SendResponse(false); |
646 } else { | 646 } else { |
647 result_.reset(Value::CreateBooleanValue(killed)); | 647 SetResult(Value::CreateBooleanValue(killed)); |
648 SendResponse(true); | 648 SendResponse(true); |
649 } | 649 } |
650 | 650 |
651 // Balance the AddRef in the RunImpl. | 651 // Balance the AddRef in the RunImpl. |
652 Release(); | 652 Release(); |
653 } | 653 } |
654 | 654 |
655 GetProcessInfoFunction::GetProcessInfoFunction() { | 655 GetProcessInfoFunction::GetProcessInfoFunction() { |
656 } | 656 } |
657 | 657 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 | 737 |
738 process_ids_.erase(proc_id); | 738 process_ids_.erase(proc_id); |
739 if (process_ids_.size() == 0) | 739 if (process_ids_.size() == 0) |
740 break; | 740 break; |
741 } | 741 } |
742 } | 742 } |
743 } | 743 } |
744 DCHECK(process_ids_.size() == 0); | 744 DCHECK(process_ids_.size() == 0); |
745 } | 745 } |
746 | 746 |
747 result_.reset(processes); | 747 SetResult(processes); |
748 SendResponse(true); | 748 SendResponse(true); |
749 | 749 |
750 // Balance the AddRef in the RunImpl. | 750 // Balance the AddRef in the RunImpl. |
751 Release(); | 751 Release(); |
752 #endif // defined(ENABLE_TASK_MANAGER) | 752 #endif // defined(ENABLE_TASK_MANAGER) |
753 } | 753 } |
OLD | NEW |