| Index: content/common/service_worker/service_worker_traits.cc
|
| diff --git a/content/common/service_worker/service_worker_traits.cc b/content/common/service_worker/service_worker_traits.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..618777126f415e67a9c386904ada95ba863ae88b
|
| --- /dev/null
|
| +++ b/content/common/service_worker/service_worker_traits.cc
|
| @@ -0,0 +1,64 @@
|
| +// 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_traits.h"
|
| +
|
| +#include "base/strings/stringprintf.h"
|
| +#include "content/common/service_worker/service_worker_client_info.h"
|
| +#include "content/public/common/common_param_traits.h"
|
| +
|
| +using content::ServiceWorkerClientInfo;
|
| +
|
| +namespace IPC {
|
| +
|
| +void ParamTraits<ServiceWorkerClientInfo>::Write(
|
| + Message* m, const ServiceWorkerClientInfo& p) {
|
| + m->WriteBool(p.IsEmpty());
|
| + if (p.IsEmpty())
|
| + return;
|
| + m->WriteInt(p.client_id());
|
| + m->WriteInt(static_cast<int>(p.page_visibility_state()));
|
| + m->WriteBool(p.is_focused());
|
| + ParamTraits<GURL>::Write(m, p.url());
|
| + m->WriteInt(static_cast<int>(p.frame_type()));
|
| +}
|
| +
|
| +bool ParamTraits<ServiceWorkerClientInfo>::Read(const Message* m,
|
| + PickleIterator* iter,
|
| + ServiceWorkerClientInfo* r) {
|
| + bool is_empty;
|
| + if (!iter->ReadBool(&is_empty))
|
| + return false;
|
| + if (is_empty) {
|
| + *r = ServiceWorkerClientInfo();
|
| + return true;
|
| + }
|
| +
|
| + GURL url;
|
| + bool is_focused;
|
| + int client_id, page_visibility_state, frame_type;
|
| +
|
| + if (!iter->ReadInt(&client_id) ||
|
| + !iter->ReadInt(&page_visibility_state) ||
|
| + !iter->ReadBool(&is_focused) ||
|
| + !ParamTraits<GURL>::Read(m, iter, &url) ||
|
| + !iter->ReadInt(&frame_type))
|
| + return false;
|
| +
|
| + ServiceWorkerClientInfo client_info(
|
| + static_cast<blink::WebPageVisibilityState>(page_visibility_state),
|
| + is_focused,
|
| + url,
|
| + static_cast<content::RequestContextFrameType>(frame_type));
|
| + client_info.SetClientID(client_id);
|
| + *r = client_info;
|
| + return true;
|
| +}
|
| +
|
| +void ParamTraits<ServiceWorkerClientInfo>::Log(const ServiceWorkerClientInfo& p,
|
| + std::string* l) {
|
| + l->append(base::StringPrintf("<ServiceWorkerClientInfo>"));
|
| +}
|
| +
|
| +}
|
|
|