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 "components/web_cache/browser/web_cache_manager.h" | 5 #include "components/web_cache/browser/web_cache_manager.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
17 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "components/prefs/pref_registry_simple.h" | 20 #include "components/prefs/pref_registry_simple.h" |
21 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
24 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
25 #include "content/public/common/service_registry.h" | 25 #include "services/shell/public/cpp/interface_provider.h" |
26 | 26 |
27 using base::Time; | 27 using base::Time; |
28 using base::TimeDelta; | 28 using base::TimeDelta; |
29 | 29 |
30 namespace web_cache { | 30 namespace web_cache { |
31 | 31 |
32 static const int kReviseAllocationDelayMS = 200; | 32 static const int kReviseAllocationDelayMS = 200; |
33 | 33 |
34 // The default size limit of the in-memory cache is 8 MB | 34 // The default size limit of the in-memory cache is 8 MB |
35 static const int kDefaultMemoryCacheSize = 8 * 1024 * 1024; | 35 static const int kDefaultMemoryCacheSize = 8 * 1024 * 1024; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 active_renderers_.insert(renderer_id); | 87 active_renderers_.insert(renderer_id); |
88 | 88 |
89 RendererInfo* stats = &(stats_[renderer_id]); | 89 RendererInfo* stats = &(stats_[renderer_id]); |
90 memset(stats, 0, sizeof(*stats)); | 90 memset(stats, 0, sizeof(*stats)); |
91 stats->access = Time::Now(); | 91 stats->access = Time::Now(); |
92 | 92 |
93 content::RenderProcessHost* host = | 93 content::RenderProcessHost* host = |
94 content::RenderProcessHost::FromID(renderer_id); | 94 content::RenderProcessHost::FromID(renderer_id); |
95 if (host) { | 95 if (host) { |
96 mojom::WebCachePtr service; | 96 mojom::WebCachePtr service; |
97 host->GetServiceRegistry()->ConnectToRemoteService( | 97 host->GetRemoteInterfaces()->GetInterface(&service); |
98 mojo::GetProxy(&service)); | |
99 web_cache_services_[renderer_id] = std::move(service); | 98 web_cache_services_[renderer_id] = std::move(service); |
100 } | 99 } |
101 | 100 |
102 // Revise our allocation strategy to account for this new renderer. | 101 // Revise our allocation strategy to account for this new renderer. |
103 ReviseAllocationStrategyLater(); | 102 ReviseAllocationStrategyLater(); |
104 } | 103 } |
105 | 104 |
106 void WebCacheManager::Remove(int renderer_id) { | 105 void WebCacheManager::Remove(int renderer_id) { |
107 // Erase all knowledge of this renderer | 106 // Erase all knowledge of this renderer |
108 active_renderers_.erase(renderer_id); | 107 active_renderers_.erase(renderer_id); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 inactive_renderers_.insert(*iter); | 473 inactive_renderers_.insert(*iter); |
475 active_renderers_.erase(*iter); | 474 active_renderers_.erase(*iter); |
476 iter = active_renderers_.begin(); | 475 iter = active_renderers_.begin(); |
477 continue; | 476 continue; |
478 } | 477 } |
479 ++iter; | 478 ++iter; |
480 } | 479 } |
481 } | 480 } |
482 | 481 |
483 } // namespace web_cache | 482 } // namespace web_cache |
OLD | NEW |