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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/common/service_worker/service_worker_client_info.h"
6
7 #include "base/logging.h"
8
9 namespace content {
10
11 ServiceWorkerClientInfo::ServiceWorkerClientInfo()
12 : empty_(true),
13 has_client_id_(false) {
14 }
15
16 ServiceWorkerClientInfo::ServiceWorkerClientInfo(
17 blink::WebPageVisibilityState page_visibility_state,
18 bool is_focused,
19 const GURL& url,
20 RequestContextFrameType frame_type)
21 : empty_(false),
22 has_client_id_(false),
23 page_visibility_state_(page_visibility_state),
24 is_focused_(is_focused),
25 url_(url),
26 frame_type_(frame_type) {
27 }
28
29 int ServiceWorkerClientInfo::client_id() const {
30 return client_id_;
31 }
32
33 blink::WebPageVisibilityState
34 ServiceWorkerClientInfo::page_visibility_state() const {
35 return page_visibility_state_;
36 }
37
38 bool ServiceWorkerClientInfo::is_focused() const {
39 return is_focused_;
40 }
41
42 const GURL& ServiceWorkerClientInfo::url() const {
43 return url_;
44 }
45
46 RequestContextFrameType ServiceWorkerClientInfo::frame_type() const {
47 return frame_type_;
48 }
49
50 void ServiceWorkerClientInfo::SetClientID(int client_id) {
51 DCHECK(!has_client_id_);
52 DCHECK(!IsEmpty());
53
54 client_id_ = client_id;
55 has_client_id_ = true;
56 }
57
58 bool ServiceWorkerClientInfo::IsEmpty() const {
59 return empty_;
60 }
61
62 bool ServiceWorkerClientInfo::IsValid() const {
63 return !empty_ && has_client_id_;
64 }
65
66 ServiceWorkerClientInfo::operator blink::WebServiceWorkerClientInfo() const {
67 DCHECK(IsValid());
68
69 blink::WebServiceWorkerClientInfo web_client_info;
70
71 web_client_info.clientID = client_id_;
72 web_client_info.pageVisibilityState = page_visibility_state_;
73 web_client_info.isFocused = is_focused_;
74 web_client_info.url = url_;
75 web_client_info.frameType =
76 static_cast<blink::WebURLRequest::FrameType>(frame_type_);
77
78 return web_client_info;
79 }
80
81 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698