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

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

Issue 2881073003: Support DataSaver for SharedWorker (Closed)
Patch Set: fix #include "public/web/WebDataSaverFlag.h" 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
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 #include "net/test/embedded_test_server/embedded_test_server.h" 75 #include "net/test/embedded_test_server/embedded_test_server.h"
76 #include "net/test/embedded_test_server/http_request.h" 76 #include "net/test/embedded_test_server/http_request.h"
77 #include "net/test/embedded_test_server/http_response.h" 77 #include "net/test/embedded_test_server/http_response.h"
78 #include "net/url_request/url_request_filter.h" 78 #include "net/url_request/url_request_filter.h"
79 #include "net/url_request/url_request_interceptor.h" 79 #include "net/url_request/url_request_interceptor.h"
80 #include "net/url_request/url_request_test_job.h" 80 #include "net/url_request/url_request_test_job.h"
81 #include "storage/browser/blob/blob_data_handle.h" 81 #include "storage/browser/blob/blob_data_handle.h"
82 #include "storage/browser/blob/blob_data_snapshot.h" 82 #include "storage/browser/blob/blob_data_snapshot.h"
83 #include "storage/browser/blob/blob_reader.h" 83 #include "storage/browser/blob/blob_reader.h"
84 #include "storage/browser/blob/blob_storage_context.h" 84 #include "storage/browser/blob/blob_storage_context.h"
85 #include "third_party/WebKit/public/web/WebDataSaverFlag.h"
85 86
86 namespace content { 87 namespace content {
87 88
88 namespace { 89 namespace {
89 90
90 struct FetchResult { 91 struct FetchResult {
91 ServiceWorkerStatusCode status; 92 ServiceWorkerStatusCode status;
92 ServiceWorkerFetchEventResult result; 93 ServiceWorkerFetchEventResult result;
93 ServiceWorkerResponse response; 94 ServiceWorkerResponse response;
94 std::unique_ptr<storage::BlobDataHandle> blob_data_handle; 95 std::unique_ptr<storage::BlobDataHandle> blob_data_handle;
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 1318
1318 void set_data_saver_enabled(bool enabled) { data_saver_enabled_ = enabled; } 1319 void set_data_saver_enabled(bool enabled) { data_saver_enabled_ = enabled; }
1319 1320
1320 // ContentBrowserClient overrides: 1321 // ContentBrowserClient overrides:
1321 bool IsDataSaverEnabled(BrowserContext* context) override { 1322 bool IsDataSaverEnabled(BrowserContext* context) override {
1322 return data_saver_enabled_; 1323 return data_saver_enabled_;
1323 } 1324 }
1324 1325
1325 void OverrideWebkitPrefs(RenderViewHost* render_view_host, 1326 void OverrideWebkitPrefs(RenderViewHost* render_view_host,
1326 WebPreferences* prefs) override { 1327 WebPreferences* prefs) override {
1327 prefs->data_saver_enabled = data_saver_enabled_; 1328 prefs->data_saver_flag = data_saver_enabled_
1329 ? blink::WebDataSaverFlag::kEnabled
1330 : blink::WebDataSaverFlag::kDisabled;
1328 } 1331 }
1329 1332
1330 private: 1333 private:
1331 bool data_saver_enabled_; 1334 bool data_saver_enabled_;
1332 }; 1335 };
1333 1336
1334 class ServiceWorkerVersionOffMainThreadFetchTest 1337 class ServiceWorkerVersionOffMainThreadFetchTest
1335 : public ServiceWorkerVersionBrowserTest { 1338 : public ServiceWorkerVersionBrowserTest {
1336 public: 1339 public:
1337 ~ServiceWorkerVersionOffMainThreadFetchTest() override {} 1340 ~ServiceWorkerVersionOffMainThreadFetchTest() override {}
(...skipping 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after
3028 // effect in CanSuspendRenderer(). 3031 // effect in CanSuspendRenderer().
3029 shell()->web_contents()->WasHidden(); 3032 shell()->web_contents()->WasHidden();
3030 EXPECT_TRUE(rph->IsProcessBackgrounded()); 3033 EXPECT_TRUE(rph->IsProcessBackgrounded());
3031 3034
3032 // The process which has service worker thread shouldn't be suspended. 3035 // The process which has service worker thread shouldn't be suspended.
3033 EXPECT_FALSE(memory_coordinator->CanSuspendRenderer(render_process_id)); 3036 EXPECT_FALSE(memory_coordinator->CanSuspendRenderer(render_process_id));
3034 } 3037 }
3035 #endif 3038 #endif
3036 3039
3037 } // namespace content 3040 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698