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

Side by Side Diff: content/browser/service_worker/service_worker_browsertest.cc

Issue 2886663002: DataSaver support for off-main-thread-fetch (Closed)
Patch Set: rebase on TOT Created 3 years, 7 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 | content/renderer/service_worker/service_worker_fetch_context_impl.h » ('j') | 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 1324
1325 void OverrideWebkitPrefs(RenderViewHost* render_view_host, 1325 void OverrideWebkitPrefs(RenderViewHost* render_view_host,
1326 WebPreferences* prefs) override { 1326 WebPreferences* prefs) override {
1327 prefs->data_saver_enabled = data_saver_enabled_; 1327 prefs->data_saver_enabled = data_saver_enabled_;
1328 } 1328 }
1329 1329
1330 private: 1330 private:
1331 bool data_saver_enabled_; 1331 bool data_saver_enabled_;
1332 }; 1332 };
1333 1333
1334 class ServiceWorkerVersionOffMainThreadFetchTest
1335 : public ServiceWorkerVersionBrowserTest {
1336 public:
1337 ~ServiceWorkerVersionOffMainThreadFetchTest() override {}
1338 void SetUpCommandLine(base::CommandLine* command_line) override {
1339 command_line->AppendSwitchASCII(switches::kEnableFeatures,
1340 features::kOffMainThreadFetch.name);
1341 }
1342 };
1343
1334 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, FetchWithSaveData) { 1344 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, FetchWithSaveData) {
1335 embedded_test_server()->RegisterRequestHandler( 1345 embedded_test_server()->RegisterRequestHandler(
1336 base::Bind(&VerifySaveDataHeaderInRequest)); 1346 base::Bind(&VerifySaveDataHeaderInRequest));
1337 StartServerAndNavigateToSetup(); 1347 StartServerAndNavigateToSetup();
1338 MockContentBrowserClient content_browser_client; 1348 MockContentBrowserClient content_browser_client;
1339 content_browser_client.set_data_saver_enabled(true); 1349 content_browser_client.set_data_saver_enabled(true);
1340 ContentBrowserClient* old_client = 1350 ContentBrowserClient* old_client =
1341 SetBrowserClientForTesting(&content_browser_client); 1351 SetBrowserClientForTesting(&content_browser_client);
1342 InstallTestHelper("/service_worker/fetch_in_install.js", SERVICE_WORKER_OK); 1352 InstallTestHelper("/service_worker/fetch_in_install.js", SERVICE_WORKER_OK);
1343 SetBrowserClientForTesting(old_client); 1353 SetBrowserClientForTesting(old_client);
1344 } 1354 }
1345 1355
1356 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionOffMainThreadFetchTest,
1357 FetchWithSaveData) {
1358 embedded_test_server()->RegisterRequestHandler(
1359 base::Bind(&VerifySaveDataHeaderInRequest));
1360 StartServerAndNavigateToSetup();
1361 MockContentBrowserClient content_browser_client;
1362 content_browser_client.set_data_saver_enabled(true);
1363 ContentBrowserClient* old_client =
1364 SetBrowserClientForTesting(&content_browser_client);
1365 InstallTestHelper("/service_worker/fetch_in_install.js", SERVICE_WORKER_OK);
1366 SetBrowserClientForTesting(old_client);
1367 }
1368
1346 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, 1369 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest,
1347 RequestWorkerScriptWithSaveData) { 1370 RequestWorkerScriptWithSaveData) {
1348 embedded_test_server()->RegisterRequestHandler( 1371 embedded_test_server()->RegisterRequestHandler(
1349 base::Bind(&VerifySaveDataHeaderInRequest)); 1372 base::Bind(&VerifySaveDataHeaderInRequest));
1350 StartServerAndNavigateToSetup(); 1373 StartServerAndNavigateToSetup();
1351 MockContentBrowserClient content_browser_client; 1374 MockContentBrowserClient content_browser_client;
1352 content_browser_client.set_data_saver_enabled(true); 1375 content_browser_client.set_data_saver_enabled(true);
1353 ContentBrowserClient* old_client = 1376 ContentBrowserClient* old_client =
1354 SetBrowserClientForTesting(&content_browser_client); 1377 SetBrowserClientForTesting(&content_browser_client);
1355 InstallTestHelper("/service_worker/generated_sw.js", SERVICE_WORKER_OK); 1378 InstallTestHelper("/service_worker/generated_sw.js", SERVICE_WORKER_OK);
(...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after
3005 // effect in CanSuspendRenderer(). 3028 // effect in CanSuspendRenderer().
3006 shell()->web_contents()->WasHidden(); 3029 shell()->web_contents()->WasHidden();
3007 EXPECT_TRUE(rph->IsProcessBackgrounded()); 3030 EXPECT_TRUE(rph->IsProcessBackgrounded());
3008 3031
3009 // The process which has service worker thread shouldn't be suspended. 3032 // The process which has service worker thread shouldn't be suspended.
3010 EXPECT_FALSE(memory_coordinator->CanSuspendRenderer(render_process_id)); 3033 EXPECT_FALSE(memory_coordinator->CanSuspendRenderer(render_process_id));
3011 } 3034 }
3012 #endif 3035 #endif
3013 3036
3014 } // namespace content 3037 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/service_worker/service_worker_fetch_context_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698