Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/crash/content/browser/crash_dump_observer_android.h" | 5 #include "components/crash/content/browser/crash_dump_observer_android.h" |
| 6 | 6 |
| 7 #include <unistd.h> | 7 #include <unistd.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 return base::Singleton<CrashDumpObserver>::get(); | 25 return base::Singleton<CrashDumpObserver>::get(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 CrashDumpObserver::CrashDumpObserver() { | 28 CrashDumpObserver::CrashDumpObserver() { |
| 29 notification_registrar_.Add(this, | 29 notification_registrar_.Add(this, |
| 30 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 30 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 31 content::NotificationService::AllSources()); | 31 content::NotificationService::AllSources()); |
| 32 notification_registrar_.Add(this, | 32 notification_registrar_.Add(this, |
| 33 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 33 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 34 content::NotificationService::AllSources()); | 34 content::NotificationService::AllSources()); |
| 35 BrowserChildProcessObserver::Add(this); | |
| 35 } | 36 } |
| 36 | 37 |
| 37 CrashDumpObserver::~CrashDumpObserver() {} | 38 CrashDumpObserver::~CrashDumpObserver() { |
| 39 BrowserChildProcessObserver::Remove(this); | |
| 40 } | |
| 38 | 41 |
| 39 void CrashDumpObserver::OnChildExitOnBlockingPool( | 42 void CrashDumpObserver::OnChildExitOnBlockingPool( |
| 40 Client* client, | 43 Client* client, |
| 41 int child_process_id, | 44 int child_process_id, |
| 42 base::ProcessHandle pid, | 45 base::ProcessHandle pid, |
| 43 content::ProcessType process_type, | 46 content::ProcessType process_type, |
| 44 base::TerminationStatus termination_status, | 47 base::TerminationStatus termination_status, |
| 45 base::android::ApplicationState app_state) { | 48 base::android::ApplicationState app_state) { |
| 46 base::AutoLock auto_lock(registered_clients_lock_); | 49 base::AutoLock auto_lock(registered_clients_lock_); |
| 47 // Only call Client::OnChildExit if we haven't been removed in the | 50 // Only call Client::OnChildExit if we haven't been removed in the |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 65 pool->PostSequencedWorkerTask( | 68 pool->PostSequencedWorkerTask( |
| 66 token, FROM_HERE, | 69 token, FROM_HERE, |
| 67 base::Bind(&CrashDumpObserver::OnChildExitOnBlockingPool, | 70 base::Bind(&CrashDumpObserver::OnChildExitOnBlockingPool, |
| 68 base::Unretained(this), client, child_process_id, pid, | 71 base::Unretained(this), client, child_process_id, pid, |
| 69 process_type, termination_status, app_state)); | 72 process_type, termination_status, app_state)); |
| 70 } | 73 } |
| 71 } | 74 } |
| 72 | 75 |
| 73 void CrashDumpObserver::RegisterClient(Client* client) { | 76 void CrashDumpObserver::RegisterClient(Client* client) { |
| 74 base::AutoLock auto_lock(registered_clients_lock_); | 77 base::AutoLock auto_lock(registered_clients_lock_); |
| 75 if (std::find(std::begin(registered_clients_), std::end(registered_clients_), | 78 if (std::find(std::begin(registered_clients_), std::end(registered_clients_), |
|
Lei Zhang
2016/09/02 01:06:14
BTW, isn't this base::ContainsValue() ?
| |
| 76 client) != std::end(registered_clients_)) { | 79 client) != std::end(registered_clients_)) { |
| 77 return; | 80 return; |
| 78 } | 81 } |
| 79 registered_clients_.push_back(client); | 82 registered_clients_.push_back(client); |
| 80 } | 83 } |
| 81 | 84 |
| 82 void CrashDumpObserver::UnregisterClient(Client* client) { | 85 void CrashDumpObserver::UnregisterClient(Client* client) { |
| 83 base::AutoLock auto_lock(registered_clients_lock_); | 86 base::AutoLock auto_lock(registered_clients_lock_); |
| 84 registered_clients_.remove(client); | 87 registered_clients_.remove(client); |
| 85 } | 88 } |
| 86 | 89 |
| 87 void CrashDumpObserver::BrowserChildProcessStarted( | 90 void CrashDumpObserver::BrowserChildProcessStarted( |
| 88 int child_process_id, | 91 int child_process_id, |
| 89 content::FileDescriptorInfo* mappings) { | 92 content::FileDescriptorInfo* mappings) { |
| 90 base::AutoLock auto_lock(registered_clients_lock_); | 93 base::AutoLock auto_lock(registered_clients_lock_); |
| 91 for (auto& client : registered_clients_) { | 94 for (auto& client : registered_clients_) { |
|
Lei Zhang
2016/09/02 01:06:14
auto*
| |
| 92 client->OnChildStart(child_process_id, mappings); | 95 client->OnChildStart(child_process_id, mappings); |
| 93 } | 96 } |
| 94 } | 97 } |
| 95 | 98 |
| 96 void CrashDumpObserver::BrowserChildProcessHostDisconnected( | 99 void CrashDumpObserver::BrowserChildProcessHostDisconnected( |
| 97 const content::ChildProcessData& data) { | 100 const content::ChildProcessData& data) { |
| 98 OnChildExit(data.id, data.handle, | 101 OnChildExit(data.id, data.handle, |
| 99 static_cast<content::ProcessType>(data.process_type), | 102 static_cast<content::ProcessType>(data.process_type), |
| 100 base::TERMINATION_STATUS_MAX_ENUM, | 103 base::TERMINATION_STATUS_MAX_ENUM, |
| 101 base::android::APPLICATION_STATE_UNKNOWN); | 104 base::android::APPLICATION_STATE_UNKNOWN); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 default: | 146 default: |
| 144 NOTREACHED(); | 147 NOTREACHED(); |
| 145 return; | 148 return; |
| 146 } | 149 } |
| 147 | 150 |
| 148 OnChildExit(rph->GetID(), rph->GetHandle(), content::PROCESS_TYPE_RENDERER, | 151 OnChildExit(rph->GetID(), rph->GetHandle(), content::PROCESS_TYPE_RENDERER, |
| 149 term_status, app_state); | 152 term_status, app_state); |
| 150 } | 153 } |
| 151 | 154 |
| 152 } // namespace breakpad | 155 } // namespace breakpad |
| OLD | NEW |