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

Side by Side Diff: content/browser/manifest/manifest_manager_host.cc

Issue 667053007: Use manifest for streamlined hosted app creation for title and URL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Fix memory leak in manifest_manager_host Created 6 years, 1 month 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
« no previous file with comments | « chrome/browser/extensions/tab_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/common/manifest_manager_messages.h" 7 #include "content/common/manifest_manager_messages.h"
8 #include "content/public/browser/render_frame_host.h" 8 #include "content/public/browser/render_frame_host.h"
9 #include "content/public/browser/render_process_host.h" 9 #include "content/public/browser/render_process_host.h"
10 #include "content/public/common/manifest.h" 10 #include "content/public/common/manifest.h"
(...skipping 26 matching lines...) Expand all
37 return it != pending_callbacks_.end() ? it->second : 0; 37 return it != pending_callbacks_.end() ? it->second : 0;
38 } 38 }
39 39
40 void ManifestManagerHost::RenderFrameDeleted( 40 void ManifestManagerHost::RenderFrameDeleted(
41 RenderFrameHost* render_frame_host) { 41 RenderFrameHost* render_frame_host) {
42 CallbackMap* callbacks = GetCallbackMapForFrame(render_frame_host); 42 CallbackMap* callbacks = GetCallbackMapForFrame(render_frame_host);
43 if (!callbacks) 43 if (!callbacks)
44 return; 44 return;
45 45
46 // Before deleting the callbacks, make sure they are called with a failure 46 // Before deleting the callbacks, make sure they are called with a failure
47 // state. 47 // state. Do this in a block so the iterator is destroyed before |callbacks|.
48 CallbackMap::const_iterator it(callbacks); 48 {
49 for (; !it.IsAtEnd(); it.Advance()) 49 CallbackMap::const_iterator it(callbacks);
50 it.GetCurrentValue()->Run(Manifest()); 50 for (; !it.IsAtEnd(); it.Advance())
51 it.GetCurrentValue()->Run(Manifest());
52 }
51 53
54 delete callbacks;
52 pending_callbacks_.erase(render_frame_host); 55 pending_callbacks_.erase(render_frame_host);
53 } 56 }
54 57
55 void ManifestManagerHost::GetManifest(RenderFrameHost* render_frame_host, 58 void ManifestManagerHost::GetManifest(RenderFrameHost* render_frame_host,
56 const GetManifestCallback& callback) { 59 const GetManifestCallback& callback) {
57 CallbackMap* callbacks = GetCallbackMapForFrame(render_frame_host); 60 CallbackMap* callbacks = GetCallbackMapForFrame(render_frame_host);
58 if (!callbacks) { 61 if (!callbacks) {
59 callbacks = new CallbackMap(); 62 callbacks = new CallbackMap();
60 pending_callbacks_[render_frame_host] = callbacks; 63 pending_callbacks_[render_frame_host] = callbacks;
61 } 64 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 129
127 callback->Run(manifest); 130 callback->Run(manifest);
128 callbacks->Remove(request_id); 131 callbacks->Remove(request_id);
129 if (callbacks->IsEmpty()) { 132 if (callbacks->IsEmpty()) {
130 delete callbacks; 133 delete callbacks;
131 pending_callbacks_.erase(render_frame_host); 134 pending_callbacks_.erase(render_frame_host);
132 } 135 }
133 } 136 }
134 137
135 } // namespace content 138 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/extensions/tab_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698