| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/manifest/manifest_manager_host.h" | 5 #include "content/browser/manifest/manifest_manager_host.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" |
| 7 #include "content/common/manifest_manager_messages.h" | 8 #include "content/common/manifest_manager_messages.h" |
| 8 #include "content/public/browser/render_frame_host.h" | 9 #include "content/public/browser/render_frame_host.h" |
| 9 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
| 10 #include "content/public/common/manifest.h" | 11 #include "content/public/common/manifest.h" |
| 11 #include "content/public/common/result_codes.h" | 12 #include "content/public/common/result_codes.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 void KillRenderer(RenderFrameHost* render_frame_host) { | 18 void KillRenderer(RenderFrameHost* render_frame_host) { |
| 18 base::ProcessHandle process_handle = | 19 base::ProcessHandle process_handle = |
| 19 render_frame_host->GetProcess()->GetHandle(); | 20 render_frame_host->GetProcess()->GetHandle(); |
| 20 if (process_handle == base::kNullProcessHandle) | 21 if (process_handle == base::kNullProcessHandle) |
| 21 return; | 22 return; |
| 22 render_frame_host->GetProcess()->Shutdown(RESULT_CODE_KILLED_BAD_MESSAGE, | 23 render_frame_host->GetProcess()->Shutdown(RESULT_CODE_KILLED_BAD_MESSAGE, |
| 23 false); | 24 false); |
| 24 } | 25 } |
| 25 | 26 |
| 26 } // anonymous namespace | 27 } // anonymous namespace |
| 27 | 28 |
| 28 ManifestManagerHost::ManifestManagerHost(WebContents* web_contents) | 29 ManifestManagerHost::ManifestManagerHost(WebContents* web_contents) |
| 29 : WebContentsObserver(web_contents) { | 30 : WebContentsObserver(web_contents) { |
| 30 } | 31 } |
| 31 | 32 |
| 32 ManifestManagerHost::~ManifestManagerHost() { | 33 ManifestManagerHost::~ManifestManagerHost() { |
| 34 STLDeleteValues(&pending_callbacks_); |
| 33 } | 35 } |
| 34 | 36 |
| 35 ManifestManagerHost::CallbackMap* ManifestManagerHost::GetCallbackMapForFrame( | 37 ManifestManagerHost::CallbackMap* ManifestManagerHost::GetCallbackMapForFrame( |
| 36 RenderFrameHost* render_frame_host) { | 38 RenderFrameHost* render_frame_host) { |
| 37 FrameCallbackMap::iterator it = pending_callbacks_.find(render_frame_host); | 39 FrameCallbackMap::iterator it = pending_callbacks_.find(render_frame_host); |
| 38 return it != pending_callbacks_.end() ? it->second : 0; | 40 return it != pending_callbacks_.end() ? it->second : 0; |
| 39 } | 41 } |
| 40 | 42 |
| 41 void ManifestManagerHost::RenderFrameDeleted( | 43 void ManifestManagerHost::RenderFrameDeleted( |
| 42 RenderFrameHost* render_frame_host) { | 44 RenderFrameHost* render_frame_host) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 132 |
| 131 callback->Run(manifest); | 133 callback->Run(manifest); |
| 132 callbacks->Remove(request_id); | 134 callbacks->Remove(request_id); |
| 133 if (callbacks->IsEmpty()) { | 135 if (callbacks->IsEmpty()) { |
| 134 delete callbacks; | 136 delete callbacks; |
| 135 pending_callbacks_.erase(render_frame_host); | 137 pending_callbacks_.erase(render_frame_host); |
| 136 } | 138 } |
| 137 } | 139 } |
| 138 | 140 |
| 139 } // namespace content | 141 } // namespace content |
| OLD | NEW |