summaryrefslogtreecommitdiffstats
path: root/chrome/browser/services/gcm/push_messaging_application_id.h
blob: 777eaf2debeea764aa010b8ff594608a2ff66d6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2014 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.

#ifndef CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_APPLICATION_ID_H_
#define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_APPLICATION_ID_H_

#include <string>

#include "base/basictypes.h"
#include "url/gurl.h"

namespace gcm {

// The prefix used for all push messaging application ids.
extern const char kPushMessagingApplicationIdPrefix[];

// Type used to identify a web app from a Push API perspective.
struct PushMessagingApplicationId {
 public:
  static PushMessagingApplicationId Parse(const std::string& id);

  PushMessagingApplicationId()
      : origin(GURL::EmptyGURL()), service_worker_registration_id(-1) {}
  PushMessagingApplicationId(const GURL& origin,
                             int64 service_worker_registration_id)
      : origin(origin),
        service_worker_registration_id(service_worker_registration_id) {}

  bool IsValid();
  std::string ToString() const;

  const GURL origin;
  const int64 service_worker_registration_id;
};

}  // namespace gcm

#endif  // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_APPLICATION_ID_H_