Chromium Code Reviews| 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..3372989451e535ac461ae072a75a8b0a8d186177 |
| --- /dev/null |
| +++ b/content/common/service_worker/service_worker_client_info.cc |
| @@ -0,0 +1,58 @@ |
| +// 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" |
| +#include "content/common/service_worker/service_worker_types.h" |
| + |
| +namespace content { |
| + |
| +ServiceWorkerClientInfo::ServiceWorkerClientInfo() |
| + : client_id(kInvalidServiceWorkerClientId), |
| + page_visibility_state(blink::WebPageVisibilityStateLast), |
| + is_focused(false), |
| + 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
|
| + frame_type(REQUEST_CONTEXT_FRAME_TYPE_LAST) { |
| +} |
| + |
| +ServiceWorkerClientInfo::ServiceWorkerClientInfo( |
| + blink::WebPageVisibilityState page_visibility_state, |
| + bool is_focused, |
| + const GURL& url, |
| + RequestContextFrameType frame_type) |
| + : 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 :)
|
| + page_visibility_state(page_visibility_state), |
| + is_focused(is_focused), |
| + url(url), |
| + frame_type(frame_type) { |
| +} |
| + |
| +bool ServiceWorkerClientInfo::IsEmpty() const { |
| + return page_visibility_state == blink::WebPageVisibilityStateLast && |
| + is_focused == false && |
| + 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
|
| + frame_type == REQUEST_CONTEXT_FRAME_TYPE_LAST; |
| +} |
| + |
| +bool ServiceWorkerClientInfo::IsValid() const { |
| + return !IsEmpty() && client_id != kInvalidServiceWorkerClientId; |
| +} |
| + |
| +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 |