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

Unified Diff: content/common/service_worker/service_worker_client_info.cc

Issue 871013003: Gather the ServiceWorker client information in the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rfh_getvisibilitystate
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/common/service_worker/service_worker_client_info.cc
diff --git a/content/common/service_worker/service_worker_client_info.cc b/content/common/service_worker/service_worker_client_info.cc
new file mode 100644
index 0000000000000000000000000000000000000000..66ed6fb0cbb7a53e2efe783ea89c7a064606e92f
--- /dev/null
+++ b/content/common/service_worker/service_worker_client_info.cc
@@ -0,0 +1,81 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/service_worker/service_worker_client_info.h"
+
+#include "base/logging.h"
+
+namespace content {
+
+ServiceWorkerClientInfo::ServiceWorkerClientInfo()
+ : empty_(true),
+ has_client_id_(false) {
+}
+
+ServiceWorkerClientInfo::ServiceWorkerClientInfo(
+ blink::WebPageVisibilityState page_visibility_state,
+ bool is_focused,
+ const GURL& url,
+ RequestContextFrameType frame_type)
+ : empty_(false),
+ has_client_id_(false),
+ page_visibility_state_(page_visibility_state),
+ is_focused_(is_focused),
+ url_(url),
+ frame_type_(frame_type) {
+}
+
+int ServiceWorkerClientInfo::client_id() const {
+ return client_id_;
+}
+
+blink::WebPageVisibilityState
+ServiceWorkerClientInfo::page_visibility_state() const {
+ return page_visibility_state_;
+}
+
+bool ServiceWorkerClientInfo::is_focused() const {
+ return is_focused_;
+}
+
+const GURL& ServiceWorkerClientInfo::url() const {
+ return url_;
+}
+
+RequestContextFrameType ServiceWorkerClientInfo::frame_type() const {
+ return frame_type_;
+}
+
+void ServiceWorkerClientInfo::SetClientID(int client_id) {
+ DCHECK(!has_client_id_);
+ DCHECK(!IsEmpty());
+
+ client_id_ = client_id;
+ has_client_id_ = true;
+}
+
+bool ServiceWorkerClientInfo::IsEmpty() const {
+ return empty_;
+}
+
+bool ServiceWorkerClientInfo::IsValid() const {
+ return !empty_ && has_client_id_;
+}
+
+ServiceWorkerClientInfo::operator blink::WebServiceWorkerClientInfo() const {
+ DCHECK(IsValid());
+
+ blink::WebServiceWorkerClientInfo web_client_info;
+
+ web_client_info.clientID = client_id_;
+ web_client_info.pageVisibilityState = page_visibility_state_;
+ web_client_info.isFocused = is_focused_;
+ web_client_info.url = url_;
+ web_client_info.frameType =
+ static_cast<blink::WebURLRequest::FrameType>(frame_type_);
+
+ return web_client_info;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698