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

Side by Side Diff: chrome/browser/memory_purger.cc

Issue 9867002: Fix link error when safe browsing is disabled. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | 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 (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/memory_purger.h" 5 #include "chrome/browser/memory_purger.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 19 matching lines...) Expand all
30 30
31 // PurgeMemoryHelper ----------------------------------------------------------- 31 // PurgeMemoryHelper -----------------------------------------------------------
32 32
33 // This is a small helper class used to ensure that the objects we want to use 33 // This is a small helper class used to ensure that the objects we want to use
34 // on multiple threads are properly refed, so they don't get deleted out from 34 // on multiple threads are properly refed, so they don't get deleted out from
35 // under us. 35 // under us.
36 class PurgeMemoryIOHelper 36 class PurgeMemoryIOHelper
37 : public base::RefCountedThreadSafe<PurgeMemoryIOHelper> { 37 : public base::RefCountedThreadSafe<PurgeMemoryIOHelper> {
38 public: 38 public:
39 PurgeMemoryIOHelper() { 39 PurgeMemoryIOHelper() {
40 #if defined(ENABLE_SAFE_BROWSING)
jam 2012/03/27 19:18:35 i think the first two ifdef's aren't needed. in ge
Iain Merrick 2012/03/28 10:25:43 Done.
40 safe_browsing_service_ = g_browser_process->safe_browsing_service(); 41 safe_browsing_service_ = g_browser_process->safe_browsing_service();
42 #endif
41 } 43 }
42 44
43 void AddRequestContextGetter( 45 void AddRequestContextGetter(
44 scoped_refptr<net::URLRequestContextGetter> request_context_getter); 46 scoped_refptr<net::URLRequestContextGetter> request_context_getter);
45 47
46 void PurgeMemoryOnIOThread(); 48 void PurgeMemoryOnIOThread();
47 49
48 private: 50 private:
49 typedef scoped_refptr<net::URLRequestContextGetter> RequestContextGetter; 51 typedef scoped_refptr<net::URLRequestContextGetter> RequestContextGetter;
50 52
51 std::vector<RequestContextGetter> request_context_getters_; 53 std::vector<RequestContextGetter> request_context_getters_;
54 #if defined(ENABLE_SAFE_BROWSING)
52 scoped_refptr<SafeBrowsingService> safe_browsing_service_; 55 scoped_refptr<SafeBrowsingService> safe_browsing_service_;
56 #endif
53 57
54 DISALLOW_COPY_AND_ASSIGN(PurgeMemoryIOHelper); 58 DISALLOW_COPY_AND_ASSIGN(PurgeMemoryIOHelper);
55 }; 59 };
56 60
57 void PurgeMemoryIOHelper::AddRequestContextGetter( 61 void PurgeMemoryIOHelper::AddRequestContextGetter(
58 scoped_refptr<net::URLRequestContextGetter> request_context_getter) { 62 scoped_refptr<net::URLRequestContextGetter> request_context_getter) {
59 request_context_getters_.push_back(request_context_getter); 63 request_context_getters_.push_back(request_context_getter);
60 } 64 }
61 65
62 void PurgeMemoryIOHelper::PurgeMemoryOnIOThread() { 66 void PurgeMemoryIOHelper::PurgeMemoryOnIOThread() {
63 // Ask ProxyServices to purge any memory they can (generally garbage in the 67 // Ask ProxyServices to purge any memory they can (generally garbage in the
64 // wrapped ProxyResolver's JS engine). 68 // wrapped ProxyResolver's JS engine).
65 for (size_t i = 0; i < request_context_getters_.size(); ++i) { 69 for (size_t i = 0; i < request_context_getters_.size(); ++i) {
66 request_context_getters_[i]->GetURLRequestContext()->proxy_service()-> 70 request_context_getters_[i]->GetURLRequestContext()->proxy_service()->
67 PurgeMemory(); 71 PurgeMemory();
68 } 72 }
69 73
74 #if defined(ENABLE_SAFE_BROWSING)
70 safe_browsing_service_->PurgeMemory(); 75 safe_browsing_service_->PurgeMemory();
76 #endif
71 } 77 }
72 78
73 // ----------------------------------------------------------------------------- 79 // -----------------------------------------------------------------------------
74 80
75 // static 81 // static
76 void MemoryPurger::PurgeAll() { 82 void MemoryPurger::PurgeAll() {
77 PurgeBrowser(); 83 PurgeBrowser();
78 PurgeRenderers(); 84 PurgeRenderers();
79 85
80 // TODO(pkasting): 86 // TODO(pkasting):
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 content::RenderProcessHost::AllHostsIterator()); 152 content::RenderProcessHost::AllHostsIterator());
147 !i.IsAtEnd(); i.Advance()) 153 !i.IsAtEnd(); i.Advance())
148 PurgeRendererForHost(i.GetCurrentValue()); 154 PurgeRendererForHost(i.GetCurrentValue());
149 } 155 }
150 156
151 // static 157 // static
152 void MemoryPurger::PurgeRendererForHost(content::RenderProcessHost* host) { 158 void MemoryPurger::PurgeRendererForHost(content::RenderProcessHost* host) {
153 // Direct the renderer to free everything it can. 159 // Direct the renderer to free everything it can.
154 host->Send(new ChromeViewMsg_PurgeMemory()); 160 host->Send(new ChromeViewMsg_PurgeMemory());
155 } 161 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698