| 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
|
|
|