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

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: review comments Created 5 years, 10 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 #include "content/common/service_worker/service_worker_types.h"
9
10 namespace content {
11
12 ServiceWorkerClientInfo::ServiceWorkerClientInfo()
13 : client_id(kInvalidServiceWorkerClientId),
14 page_visibility_state(blink::WebPageVisibilityStateLast),
15 is_focused(false),
16 url(GURL()),
michaeln 2015/01/27 23:12:57 empty GURL() value isn't needed in the init list
mlamouri (slow - plz ping) 2015/01/28 11:35:05 Removed. I wanted to have it here to be explicit b
17 frame_type(REQUEST_CONTEXT_FRAME_TYPE_LAST) {
18 }
19
20 ServiceWorkerClientInfo::ServiceWorkerClientInfo(
21 blink::WebPageVisibilityState page_visibility_state,
22 bool is_focused,
23 const GURL& url,
24 RequestContextFrameType frame_type)
25 : client_id(kInvalidServiceWorkerClientId),
michaeln 2015/01/27 23:12:56 indents are off here Foo::Foo( int x, int
mlamouri (slow - plz ping) 2015/01/28 11:35:05 I will never get used to that :)
26 page_visibility_state(page_visibility_state),
27 is_focused(is_focused),
28 url(url),
29 frame_type(frame_type) {
30 }
31
32 bool ServiceWorkerClientInfo::IsEmpty() const {
33 return page_visibility_state == blink::WebPageVisibilityStateLast &&
34 is_focused == false &&
35 url.is_empty() &&
michaeln 2015/01/27 23:12:56 are all of these required for IsEmpty() test or wo
mlamouri (slow - plz ping) 2015/01/28 11:35:05 It's hard to have strong requirements there becaus
36 frame_type == REQUEST_CONTEXT_FRAME_TYPE_LAST;
37 }
38
39 bool ServiceWorkerClientInfo::IsValid() const {
40 return !IsEmpty() && client_id != kInvalidServiceWorkerClientId;
41 }
42
43 ServiceWorkerClientInfo::operator blink::WebServiceWorkerClientInfo() const {
44 DCHECK(IsValid());
45
46 blink::WebServiceWorkerClientInfo web_client_info;
47
48 web_client_info.clientID = client_id;
49 web_client_info.pageVisibilityState = page_visibility_state;
50 web_client_info.isFocused = is_focused;
51 web_client_info.url = url;
52 web_client_info.frameType =
53 static_cast<blink::WebURLRequest::FrameType>(frame_type);
54
55 return web_client_info;
56 }
57
58 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698