Merge lp:~abreu-alexandre/oxide/limit-discardable-memory-19 into lp:oxide/1.9

Proposed by Alexandre Abreu on 2015-09-29
Status: Merged
Merged at revision: 1184
Proposed branch: lp:~abreu-alexandre/oxide/limit-discardable-memory-19
Merge into: lp:oxide/1.9
Diff against target: 618 lines (+133/-153)
13 files modified
patches/limit-max-decoded-image-bytes-on-mobile.patch (+19/-62)
patches/series (+3/-1)
shared/app/oxide_content_main_delegate.cc (+26/-1)
shared/browser/oxide_browser_process_main.cc (+39/-30)
shared/browser/oxide_content_browser_client.cc (+2/-3)
shared/browser/oxide_form_factor_detection_linux.cc (+13/-40)
shared/browser/oxide_power_save_blocker.cc (+1/-1)
shared/browser/oxide_renderer_frame_evictor.cc (+2/-1)
shared/common/oxide_content_client.cc (+12/-2)
shared/common/oxide_content_client.h (+2/-1)
shared/common/oxide_form_factor.h (+6/-4)
shared/renderer/oxide_content_renderer_client.cc (+3/-5)
shared/shared.gyp (+5/-2)
To merge this branch: bzr merge lp:~abreu-alexandre/oxide/limit-discardable-memory-19
Reviewer Review Type Date Requested Status
Chris Coulson 2015-09-29 Approve on 2015-09-30
Review via email: mp+272682@code.launchpad.net

Description of the change

Backport the limit discardable memory on mobile

To post a comment you must log in.
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'patches/add-limit-max-decoded-image-bytes-switch.patch' => 'patches/limit-max-decoded-image-bytes-on-mobile.patch'
2--- patches/add-limit-max-decoded-image-bytes-switch.patch 2015-06-25 08:52:03 +0000
3+++ patches/limit-max-decoded-image-bytes-on-mobile.patch 2015-09-29 13:54:38 +0000
4@@ -3,14 +3,10 @@
5 # Author: Chris Coulson <chris.coulson@canonical.com>
6
7 diff --git a/content/child/blink_platform_impl.cc b/content/child/blink_platform_impl.cc
8+index 1fbb0a5..43d3aa0 100644
9 --- a/content/child/blink_platform_impl.cc
10 +++ b/content/child/blink_platform_impl.cc
11-@@ -5,16 +5,17 @@
12- #include "content/child/blink_platform_impl.h"
13-
14- #include <math.h>
15-
16- #include <vector>
17+@@ -10,6 +10,7 @@
18
19 #include "base/allocator/allocator_extension.h"
20 #include "base/bind.h"
21@@ -18,17 +14,7 @@
22 #include "base/files/file_path.h"
23 #include "base/location.h"
24 #include "base/memory/scoped_ptr.h"
25- #include "base/memory/singleton.h"
26- #include "base/metrics/histogram.h"
27- #include "base/metrics/sparse_histogram.h"
28- #include "base/process/process_metrics.h"
29- #include "base/rand_util.h"
30-@@ -54,16 +55,17 @@
31- #include "content/child/web_discardable_memory_impl.h"
32- #include "content/child/web_memory_dump_provider_adapter.h"
33- #include "content/child/web_process_memory_dump_impl.h"
34- #include "content/child/web_url_loader_impl.h"
35- #include "content/child/web_url_request_util.h"
36+@@ -59,6 +60,7 @@
37 #include "content/child/websocket_bridge.h"
38 #include "content/child/worker_task_runner.h"
39 #include "content/public/common/content_client.h"
40@@ -36,36 +22,19 @@
41 #include "net/base/data_url.h"
42 #include "net/base/ip_address_number.h"
43 #include "net/base/net_errors.h"
44- #include "net/base/net_util.h"
45- #include "third_party/WebKit/public/platform/WebConvertableToTraceFormat.h"
46- #include "third_party/WebKit/public/platform/WebData.h"
47- #include "third_party/WebKit/public/platform/WebFloatPoint.h"
48- #include "third_party/WebKit/public/platform/WebMemoryDumpProvider.h"
49-@@ -1281,33 +1283,34 @@ bool BlinkPlatformImpl::memoryAllocatorW
50- }
51-
52- blink::WebDiscardableMemory*
53- BlinkPlatformImpl::allocateAndLockDiscardableMemory(size_t bytes) {
54- return content::WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release();
55+@@ -1336,7 +1338,10 @@ BlinkPlatformImpl::allocateAndLockDiscardableMemory(size_t bytes) {
56 }
57
58 size_t BlinkPlatformImpl::maxDecodedImageBytes() {
59 -#if defined(OS_ANDROID)
60-+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
61-+ switches::kLimitMaxDecodedImageBytes)) {
62++ if (!GetContentClient()->ShouldOptimizeForMemoryUsage()) {
63 + return noDecodedImageByteLimit;
64 + }
65 +
66 if (base::SysInfo::IsLowEndDevice()) {
67 // Limit image decoded size to 3M pixels on low end devices.
68 // 4 is maximum number of bytes per pixel.
69- return 3 * 1024 * 1024 * 4;
70- }
71- // For other devices, limit decoded image size based on the amount of physical
72- // memory.
73- // In some cases all physical memory is not accessible by Chromium, as it can
74- // be reserved for direct use by certain hardware. Thus, we set the limit so
75- // that 1.6GB of reported physical memory on a 2GB device is enough to set the
76+@@ -1350,9 +1355,6 @@ size_t BlinkPlatformImpl::maxDecodedImageBytes() {
77 // limit at 16M pixels, which is a desirable value since 4K*4K is a relatively
78 // common texture size.
79 return base::SysInfo::AmountOfPhysicalMemory() / 25;
80@@ -75,20 +44,10 @@
81 }
82
83 uint32_t BlinkPlatformImpl::getUniqueIdForProcess() {
84- // TODO(rickyz): Replace this with base::GetUniqueIdForProcess when that's
85- // ready.
86- return base::trace_event::TraceLog::GetInstance()->process_id();
87- }
88-
89 diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
90 --- a/content/public/common/content_switches.cc
91 +++ b/content/public/common/content_switches.cc
92-@@ -560,16 +560,19 @@ const char kInProcessGPU[]
93-
94- // Overrides the timeout, in seconds, that a child process waits for a
95- // connection from the browser before killing itself.
96- const char kIPCConnectionTimeout[] = "ipc-connection-timeout";
97-
98+@@ -570,6 +570,9 @@ const char kIPCConnectionTimeout[] = "ipc-connection-timeout";
99 // Specifies the flags passed to JS engine
100 const char kJavaScriptFlags[] = "js-flags";
101
102@@ -98,29 +57,27 @@
103 // Load an NPAPI plugin from the specified path.
104 const char kLoadPlugin[] = "load-plugin";
105
106- // Logs GPU control list decisions when enforcing blacklist rules.
107- const char kLogGpuControlListDecisions[] = "log-gpu-control-list-decisions";
108-
109- // Sets the minimum log level. Valid values are from 0 to 3:
110- // INFO = 0, WARNING = 1, LOG_ERROR = 2, LOG_FATAL = 3.
111 diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
112 --- a/content/public/common/content_switches.h
113 +++ b/content/public/common/content_switches.h
114-@@ -161,16 +161,17 @@ CONTENT_EXPORT extern const char kGpuSan
115- CONTENT_EXPORT extern const char kGpuStartupDialog[];
116- extern const char kGpuVendorID[];
117+@@ -164,9 +164,10 @@ extern const char kGpuVendorID[];
118 CONTENT_EXPORT extern const char kHostResolverRules[];
119 CONTENT_EXPORT extern const char kIgnoreCertificateErrors[];
120 CONTENT_EXPORT extern const char kIgnoreGpuBlacklist[];
121- CONTENT_EXPORT extern const char kInProcessGPU[];
122+-extern const char kInProcessGPU[];
123++CONTENT_EXPORT extern const char kInProcessGPU[];
124 CONTENT_EXPORT extern const char kIPCConnectionTimeout[];
125 CONTENT_EXPORT extern const char kJavaScriptFlags[];
126 +CONTENT_EXPORT extern const char kLimitMaxDecodedImageBytes[];
127 extern const char kLoadPlugin[];
128 CONTENT_EXPORT extern const char kLogGpuControlListDecisions[];
129 CONTENT_EXPORT extern const char kLoggingLevel[];
130- CONTENT_EXPORT extern const char kLogNetLog[];
131- extern const char kLogPluginMessages[];
132- CONTENT_EXPORT extern const char kMainFrameResizesAreOrientationChanges[];
133- extern const char kMaxUntiledLayerHeight[];
134- extern const char kMaxUntiledLayerWidth[];
135+@@ -200,7 +201,7 @@ CONTENT_EXPORT extern const char kReduceSecurityForTesting[];
136+ CONTENT_EXPORT extern const char kReducedReferrerGranularity[];
137+ CONTENT_EXPORT extern const char kRegisterPepperPlugins[];
138+ CONTENT_EXPORT extern const char kRemoteDebuggingPort[];
139+-extern const char kRendererCmdPrefix[];
140++CONTENT_EXPORT extern const char kRendererCmdPrefix[];
141+ CONTENT_EXPORT extern const char kRendererProcess[];
142+ CONTENT_EXPORT extern const char kRendererProcessLimit[];
143+ CONTENT_EXPORT extern const char kRendererStartupDialog[];
144
145=== modified file 'patches/series'
146--- patches/series 2015-06-29 11:25:34 +0000
147+++ patches/series 2015-09-29 13:54:38 +0000
148@@ -21,7 +21,8 @@
149 store-cache-stats-at-startup.patch
150 export-content-switches.patch
151 fix-non-x11-build.patch
152-add-limit-max-decoded-image-bytes-switch.patch
153+add-optimize-for-memory-to-content-client.patch
154+limit-max-decoded-image-bytes-on-mobile.patch
155 customize-gesture-fling-curve.patch
156 mediahub-support.patch
157 allow-os-override-for-gpu-manager.patch
158@@ -34,3 +35,4 @@
159 implement-webrtc-get-cpu-features-arm.patch
160 enable-optional-neon-for-skia.patch
161 add-suggested-filename-to-download-starting-resource-delegate.patch
162+lower-limit-for-discardable-memory-on-mobile.patch
163\ No newline at end of file
164
165=== modified file 'shared/app/oxide_content_main_delegate.cc'
166--- shared/app/oxide_content_main_delegate.cc 2015-06-12 07:39:38 +0000
167+++ shared/app/oxide_content_main_delegate.cc 2015-09-29 13:54:38 +0000
168@@ -1,5 +1,5 @@
169 // vim:expandtab:shiftwidth=2:tabstop=2:
170-// Copyright (C) 2013 Canonical Ltd.
171+// Copyright (C) 2013-2015 Canonical Ltd.
172
173 // This library is free software; you can redistribute it and/or
174 // modify it under the terms of the GNU Lesser General Public
175@@ -35,7 +35,9 @@
176
177 #include "shared/browser/oxide_browser_process_main.h"
178 #include "shared/browser/oxide_content_browser_client.h"
179+#include "shared/common/oxide_constants.h"
180 #include "shared/common/oxide_content_client.h"
181+#include "shared/common/oxide_form_factor.h"
182 #include "shared/common/oxide_paths.h"
183 #include "shared/renderer/oxide_content_renderer_client.h"
184
185@@ -43,6 +45,25 @@
186
187 namespace oxide {
188
189+namespace {
190+
191+FormFactor FormFactorHintFromCommandLine(base::CommandLine* command_line) {
192+ std::string form_factor =
193+ command_line->GetSwitchValueASCII(switches::kFormFactor);
194+ if (form_factor == switches::kFormFactorDesktop) {
195+ return FORM_FACTOR_DESKTOP;
196+ } else if (form_factor == switches::kFormFactorTablet) {
197+ return FORM_FACTOR_TABLET;
198+ } else if (form_factor == switches::kFormFactorPhone) {
199+ return FORM_FACTOR_PHONE;
200+ }
201+
202+ NOTREACHED();
203+ return FORM_FACTOR_DESKTOP;
204+}
205+
206+}
207+
208 ContentMainDelegate::ContentMainDelegate(PlatformDelegate* delegate)
209 : delegate_(delegate) {
210 CHECK(delegate_);
211@@ -55,6 +76,10 @@
212 content::SetContentClient(content_client_.get());
213 RegisterPathProvider();
214
215+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
216+ if (command_line->HasSwitch(switches::kProcessType)) {
217+ InitFormFactorHint(FormFactorHintFromCommandLine(command_line));
218+ }
219 return false;
220 }
221
222
223=== modified file 'shared/browser/oxide_browser_process_main.cc'
224--- shared/browser/oxide_browser_process_main.cc 2015-09-10 08:31:38 +0000
225+++ shared/browser/oxide_browser_process_main.cc 2015-09-29 13:54:38 +0000
226@@ -65,10 +65,11 @@
227 #include "shared/app/oxide_platform_delegate.h"
228 #include "shared/common/oxide_constants.h"
229 #include "shared/common/oxide_content_client.h"
230+#include "shared/common/oxide_form_factor.h"
231
232 #include "oxide_android_properties.h"
233 #include "oxide_browser_context.h"
234-#include "oxide_form_factor.h"
235+#include "oxide_form_factor_detection.h"
236 #include "oxide_message_pump.h"
237 #include "oxide_web_contents_unloader.h"
238
239@@ -328,36 +329,17 @@
240 }
241
242 void AddFormFactorSpecificCommandLineArguments() {
243+ if (GetFormFactorHint() == FORM_FACTOR_DESKTOP) {
244+ return;
245+ }
246+
247 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
248-
249- FormFactor form_factor = GetFormFactorHint();
250-
251- if (form_factor != FORM_FACTOR_DESKTOP) {
252- command_line->AppendSwitch(switches::kEnableViewport);
253- command_line->AppendSwitch(switches::kEnableViewportMeta);
254- command_line->AppendSwitch(switches::kMainFrameResizesAreOrientationChanges);
255- command_line->AppendSwitch(switches::kEnablePinch);
256- // Note, overlay scrollbars do not work properly on desktop yet
257- // see https://launchpad.net/bugs/1426567
258- command_line->AppendSwitch(switches::kEnableOverlayScrollbar);
259- command_line->AppendSwitch(switches::kLimitMaxDecodedImageBytes);
260- }
261-
262- const char* form_factor_string = nullptr;
263- switch (form_factor) {
264- case FORM_FACTOR_DESKTOP:
265- form_factor_string = switches::kFormFactorDesktop;
266- break;
267- case FORM_FACTOR_TABLET:
268- form_factor_string = switches::kFormFactorTablet;
269- break;
270- case FORM_FACTOR_PHONE:
271- form_factor_string = switches::kFormFactorPhone;
272- break;
273- default:
274- NOTREACHED();
275- }
276- command_line->AppendSwitchASCII(switches::kFormFactor, form_factor_string);
277+ command_line->AppendSwitch(switches::kEnableViewport);
278+ command_line->AppendSwitch(switches::kMainFrameResizesAreOrientationChanges);
279+ command_line->AppendSwitch(switches::kEnablePinch);
280+ // Note, overlay scrollbars do not work properly on desktop yet
281+ // see https://launchpad.net/bugs/1426567
282+ command_line->AppendSwitch(switches::kEnableOverlayScrollbar);
283 }
284
285 bool IsUnsupportedProcessModel(ProcessModel process_model) {
286@@ -372,6 +354,20 @@
287 }
288 }
289
290+const char* GetFormFactorHintCommandLine(FormFactor form_factor) {
291+ switch (form_factor) {
292+ case FORM_FACTOR_DESKTOP:
293+ return switches::kFormFactorDesktop;
294+ case FORM_FACTOR_TABLET:
295+ return switches::kFormFactorTablet;
296+ case FORM_FACTOR_PHONE:
297+ return switches::kFormFactorPhone;
298+ }
299+
300+ NOTREACHED();
301+ return nullptr;
302+}
303+
304 }
305
306 BrowserProcessMainImpl::BrowserProcessMainImpl()
307@@ -431,6 +427,19 @@
308 base::CommandLine::ForCurrentProcess()->HasSwitch(
309 switches::kSingleProcess));
310
311+ // Ideally we'd do this before calling
312+ // ContentMainDelegate::BasicStartupComplete, and then ContentMainDelegate
313+ // would call InitFormFactorHint for all process types. However,
314+ // DetectFormFactorHint depends on BrowserPlatformIntegration, which is
315+ // initialized when ContentBrowserClient is created. Perhaps we could create
316+ // BPI earlier?
317+ FormFactor form_factor = DetectFormFactorHint();
318+ base::CommandLine::ForCurrentProcess()
319+ ->AppendSwitchASCII(switches::kFormFactor,
320+ GetFormFactorHintCommandLine(form_factor));
321+
322+ InitFormFactorHint(form_factor);
323+
324 AddFormFactorSpecificCommandLineArguments();
325
326 #if defined(USE_NSS_CERTS)
327
328=== modified file 'shared/browser/oxide_content_browser_client.cc'
329--- shared/browser/oxide_content_browser_client.cc 2015-06-29 22:44:52 +0000
330+++ shared/browser/oxide_content_browser_client.cc 2015-09-29 13:54:38 +0000
331@@ -37,6 +37,7 @@
332 #include "shared/browser/media/oxide_media_capture_devices_dispatcher.h"
333 #include "shared/common/oxide_constants.h"
334 #include "shared/common/oxide_content_client.h"
335+#include "shared/common/oxide_form_factor.h"
336
337 #include "oxide_access_token_store.h"
338 #include "oxide_android_properties.h"
339@@ -44,7 +45,6 @@
340 #include "oxide_browser_main_parts.h"
341 #include "oxide_browser_platform_integration.h"
342 #include "oxide_browser_process_main.h"
343-#include "oxide_form_factor.h"
344 #include "oxide_quota_permission_context.h"
345 #include "oxide_render_message_filter.h"
346 #include "oxide_resource_dispatcher_host_delegate.h"
347@@ -105,9 +105,8 @@
348 // This can be called on the UI or IO thread
349 static const char* const kSwitchNames[] = {
350 switches::kEnableGoogleTalkPlugin,
351+ switches::kEnableMediaHubAudio,
352 switches::kFormFactor,
353- switches::kLimitMaxDecodedImageBytes,
354- switches::kEnableMediaHubAudio,
355 switches::kMediaHubFixedSessionDomains
356 };
357 command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
358
359=== renamed file 'shared/browser/oxide_form_factor_linux.cc' => 'shared/browser/oxide_form_factor_detection_linux.cc'
360--- shared/browser/oxide_form_factor_linux.cc 2015-01-21 22:58:10 +0000
361+++ shared/browser/oxide_form_factor_detection_linux.cc 2015-09-29 13:54:38 +0000
362@@ -1,5 +1,5 @@
363 // vim:expandtab:shiftwidth=2:tabstop=2:
364-// Copyright (C) 2013-2014 Canonical Ltd.
365+// Copyright (C) 2013-2015 Canonical Ltd.
366
367 // This library is free software; you can redistribute it and/or
368 // modify it under the terms of the GNU Lesser General Public
369@@ -15,47 +15,20 @@
370 // License along with this library; if not, write to the Free Software
371 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
372
373-#include "oxide_form_factor.h"
374+#include "oxide_form_factor_detection.h"
375
376 #include <algorithm>
377
378-#include "base/logging.h"
379 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
380
381+#include "shared/common/oxide_form_factor.h"
382+
383 #include "oxide_android_properties.h"
384 #include "oxide_browser_platform_integration.h"
385
386 namespace oxide {
387
388-FormFactor GetFormFactorHint() {
389- static bool initialized = false;
390- static FormFactor form_factor = FORM_FACTOR_DESKTOP;
391-
392- if (initialized) {
393- return form_factor;
394- }
395-
396- const char* force = getenv("OXIDE_FORCE_FORM_FACTOR");
397- if (force) {
398- initialized = true;
399- if (!strcmp(force, "desktop")) {
400- form_factor = FORM_FACTOR_DESKTOP;
401- } else if (!strcmp(force, "tablet")) {
402- form_factor = FORM_FACTOR_TABLET;
403- } else if (!strcmp(force, "phone")) {
404- form_factor = FORM_FACTOR_PHONE;
405- } else {
406- LOG(ERROR) << "Unrecognized value for OXIDE_FORCE_FORM_FACTOR";
407- initialized = false;
408- }
409- }
410-
411- if (initialized) {
412- return form_factor;
413- }
414-
415- initialized = true;
416-
417+FormFactor DetectFormFactorHintImpl() {
418 if (AndroidProperties::GetInstance()->Available()) {
419 // Ubuntu on phones and tablets currently uses an Android kernel and EGL
420 // stack. If we detect these, assume we are a phone or tablet. The screen
421@@ -65,17 +38,17 @@
422 BrowserPlatformIntegration::GetInstance()->GetDefaultScreenInfo());
423 if (std::min(screen.rect.width / screen.deviceScaleFactor,
424 screen.rect.height / screen.deviceScaleFactor) >= 600) {
425- form_factor = FORM_FACTOR_TABLET;
426- } else {
427- form_factor = FORM_FACTOR_PHONE;
428+ return FORM_FACTOR_TABLET;
429 }
430- } else {
431- // If this is not an Ubuntu phone or tablet, assume desktop linux for now.
432- // We could be cleverer here, eg, using /sys/class/dmi/id/chassis_type
433- // or something like that. But this is good enough for now
434+
435+ return FORM_FACTOR_PHONE;
436 }
437
438- return form_factor;
439+ // If this is not an Ubuntu phone or tablet, assume desktop linux for now.
440+ // We could be cleverer here, eg, using /sys/class/dmi/id/chassis_type
441+ // or something like that. But this is good enough for now
442+
443+ return FORM_FACTOR_DESKTOP;
444 }
445
446 } // namespace oxide
447
448=== modified file 'shared/browser/oxide_power_save_blocker.cc'
449--- shared/browser/oxide_power_save_blocker.cc 2015-07-22 04:33:55 +0000
450+++ shared/browser/oxide_power_save_blocker.cc 2015-09-29 13:54:38 +0000
451@@ -29,11 +29,11 @@
452 #include "dbus/object_path.h"
453 #include "dbus/object_proxy.h"
454
455+#include "shared/common/oxide_form_factor.h"
456 #include "shared/port/content/browser/power_save_blocker_oxide.h"
457
458 #include "oxide_browser_platform_integration.h"
459 #include "oxide_browser_platform_integration_observer.h"
460-#include "oxide_form_factor.h"
461
462 namespace oxide {
463
464
465=== modified file 'shared/browser/oxide_renderer_frame_evictor.cc'
466--- shared/browser/oxide_renderer_frame_evictor.cc 2014-06-24 00:33:34 +0000
467+++ shared/browser/oxide_renderer_frame_evictor.cc 2015-09-29 13:54:38 +0000
468@@ -23,7 +23,8 @@
469 #include "base/sys_info.h"
470 #include "content/common/host_shared_bitmap_manager.h"
471
472-#include "oxide_form_factor.h"
473+#include "shared/common/oxide_form_factor.h"
474+
475 #include "oxide_renderer_frame_evictor_client.h"
476
477 namespace oxide {
478
479=== modified file 'shared/common/oxide_content_client.cc'
480--- shared/common/oxide_content_client.cc 2015-04-09 22:20:49 +0000
481+++ shared/common/oxide_content_client.cc 2015-09-29 13:54:38 +0000
482@@ -1,5 +1,5 @@
483 // vim:expandtab:shiftwidth=2:tabstop=2:
484-// Copyright (C) 2013 Canonical Ltd.
485+// Copyright (C) 2013-2015 Canonical Ltd.
486
487 // This library is free software; you can redistribute it and/or
488 // modify it under the terms of the GNU Lesser General Public
489@@ -27,6 +27,7 @@
490 #include "shared/browser/oxide_content_browser_client.h"
491 #include "shared/renderer/oxide_content_renderer_client.h"
492
493+#include "oxide_form_factor.h"
494 #include "oxide_user_agent.h"
495
496 namespace oxide {
497@@ -55,7 +56,16 @@
498
499 base::RefCountedStaticMemory* ContentClient::GetDataResourceBytes(
500 int resource_id) const {
501- return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id);
502+ return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
503+ resource_id);
504+}
505+
506+bool ContentClient::ShouldOptimizeForMemoryUsage() const {
507+ if (GetFormFactorHint() == FORM_FACTOR_DESKTOP) {
508+ return false;
509+ }
510+
511+ return true;
512 }
513
514 // static
515
516=== modified file 'shared/common/oxide_content_client.h'
517--- shared/common/oxide_content_client.h 2014-11-08 01:06:30 +0000
518+++ shared/common/oxide_content_client.h 2015-09-29 13:54:38 +0000
519@@ -1,5 +1,5 @@
520 // vim:expandtab:shiftwidth=2:tabstop=2:
521-// Copyright (C) 2013 Canonical Ltd.
522+// Copyright (C) 2013-2015 Canonical Ltd.
523
524 // This library is free software; you can redistribute it and/or
525 // modify it under the terms of the GNU Lesser General Public
526@@ -47,6 +47,7 @@
527 ui::ScaleFactor scale_factor) const final;
528 base::RefCountedStaticMemory* GetDataResourceBytes(
529 int resource_id) const final;
530+ bool ShouldOptimizeForMemoryUsage() const final;
531
532 DISALLOW_COPY_AND_ASSIGN(ContentClient);
533 };
534
535=== renamed file 'shared/browser/oxide_form_factor.h' => 'shared/common/oxide_form_factor.h'
536--- shared/browser/oxide_form_factor.h 2014-02-13 16:04:31 +0000
537+++ shared/common/oxide_form_factor.h 2015-09-29 13:54:38 +0000
538@@ -1,5 +1,5 @@
539 // vim:expandtab:shiftwidth=2:tabstop=2:
540-// Copyright (C) 2013 Canonical Ltd.
541+// Copyright (C) 2013-2015 Canonical Ltd.
542
543 // This library is free software; you can redistribute it and/or
544 // modify it under the terms of the GNU Lesser General Public
545@@ -15,8 +15,8 @@
546 // License along with this library; if not, write to the Free Software
547 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
548
549-#ifndef _OXIDE_SHARED_BROWSER_FORM_FACTOR_H_
550-#define _OXIDE_SHARED_BROWSER_FORM_FACTOR_H_
551+#ifndef _OXIDE_SHARED_COMMON_FORM_FACTOR_H_
552+#define _OXIDE_SHARED_COMMON_FORM_FACTOR_H_
553
554 namespace oxide {
555
556@@ -26,8 +26,10 @@
557 FORM_FACTOR_PHONE
558 };
559
560+void InitFormFactorHint(FormFactor form_factor);
561+
562 FormFactor GetFormFactorHint();
563
564 }
565
566-#endif // _OXIDE_SHARED_BROWSER_FORM_FACTOR_H_
567+#endif // _OXIDE_SHARED_COMMON_FORM_FACTOR_H_
568
569=== modified file 'shared/renderer/oxide_content_renderer_client.cc'
570--- shared/renderer/oxide_content_renderer_client.cc 2015-06-29 16:47:46 +0000
571+++ shared/renderer/oxide_content_renderer_client.cc 2015-09-29 13:54:38 +0000
572@@ -35,6 +35,7 @@
573
574 #include "shared/common/chrome_version.h"
575 #include "shared/common/oxide_constants.h"
576+#include "shared/common/oxide_form_factor.h"
577 #include "shared/common/oxide_net_resource_provider.h"
578
579 #include "oxide_renderer_user_agent_settings.h"
580@@ -85,11 +86,8 @@
581 blink::WebSettings* settings = render_view->GetWebView()->settings();
582 settings->setDoubleTapToZoomEnabled(true); // XXX: Make this configurable
583
584- std::string form_factor =
585- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
586- switches::kFormFactor);
587- if (form_factor == switches::kFormFactorTablet ||
588- form_factor == switches::kFormFactorPhone) {
589+ if (GetFormFactorHint() == FORM_FACTOR_TABLET ||
590+ GetFormFactorHint() == FORM_FACTOR_PHONE) {
591 settings->setAllowCustomScrollbarInMainFrame(false);
592 settings->setUseWideViewport(true);
593 settings->setMainFrameClipsContent(false);
594
595=== modified file 'shared/shared.gyp'
596--- shared/shared.gyp 2015-07-01 09:56:23 +0000
597+++ shared/shared.gyp 2015-09-29 13:54:38 +0000
598@@ -341,8 +341,9 @@
599 'browser/oxide_event_utils.h',
600 'browser/oxide_file_picker.cc',
601 'browser/oxide_file_picker.h',
602- 'browser/oxide_form_factor.h',
603- 'browser/oxide_form_factor_linux.cc',
604+ 'browser/oxide_form_factor_detection.cc',
605+ 'browser/oxide_form_factor_detection.h',
606+ 'browser/oxide_form_factor_detection_linux.cc',
607 'browser/oxide_gesture_provider.cc',
608 'browser/oxide_gesture_provider.h',
609 'browser/oxide_gpu_info_collector_linux.cc',
610@@ -448,6 +449,8 @@
611 'common/oxide_export.h',
612 'common/oxide_file_utils.cc',
613 'common/oxide_file_utils.h',
614+ 'common/oxide_form_factor.cc',
615+ 'common/oxide_form_factor.h',
616 'common/oxide_id_allocator.cc',
617 'common/oxide_id_allocator.h',
618 'common/oxide_message_enums.h',

Subscribers

People subscribed via source and target branches