1a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// found in the LICENSE file.
4a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
5a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
6a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
7a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
8a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include <map>
95c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include <vector>
10a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
11a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "base/basictypes.h"
12a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "base/callback_forward.h"
13a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "base/gtest_prod_util.h"
14a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "base/logging.h"
15a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "base/memory/ref_counted.h"
16cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "base/memory/weak_ptr.h"
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/observer_list.h"
180529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "base/strings/string16.h"
19a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "content/common/content_export.h"
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "content/common/service_worker/service_worker_status_code.h"
21cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "url/gurl.h"
22a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
23cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)struct EmbeddedWorkerMsg_StartWorker_Params;
24a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace IPC {
265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class Message;
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
29a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)namespace content {
30a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
31a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class EmbeddedWorkerRegistry;
32cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class ServiceWorkerContextCore;
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct ServiceWorkerFetchRequest;
34a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
35a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// This gives an interface to control one EmbeddedWorker instance, which
36a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// may be 'in-waiting' or running in one of the child processes added by
37a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// AddProcessReference().
38a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class CONTENT_EXPORT EmbeddedWorkerInstance {
39a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) public:
405c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback;
41a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  enum Status {
42a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    STOPPED,
43a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    STARTING,
44a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    RUNNING,
45a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    STOPPING,
46a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  };
47a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
480529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  class Listener {
495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)   public:
500529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    virtual ~Listener() {}
515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    virtual void OnStarted() = 0;
525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    virtual void OnStopped() = 0;
530529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    virtual void OnReportException(const base::string16& error_message,
540529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                   int line_number,
550529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                   int column_number,
560529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                   const GURL& source_url) {}
570529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    virtual void OnReportConsoleMessage(int source_identifier,
580529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                        int message_level,
590529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                        const base::string16& message,
600529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                        int line_number,
610529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                        const GURL& source_url) {}
620529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    // These should return false if the message is not handled by this
630529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    // listener. (TODO(kinuko): consider using IPC::Listener interface)
640529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    // TODO(kinuko): Deprecate OnReplyReceived.
650529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    virtual bool OnMessageReceived(const IPC::Message& message) = 0;
665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  };
675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
68a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  ~EmbeddedWorkerInstance();
69a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
705c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // Starts the worker. It is invalid to call this when the worker is not in
715c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // STOPPED status. |callback| is invoked when the worker's process is created
725c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // if necessary and the IPC to evaluate the worker's script is sent.
735c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // Observer::OnStarted() is run when the worker is actually started.
745c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  void Start(int64 service_worker_version_id,
755c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu             const GURL& scope,
765c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu             const GURL& script_url,
775c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu             const std::vector<int>& possible_process_ids,
785c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu             const StatusCallback& callback);
79a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
80a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Stops the worker. It is invalid to call this when the worker is
81a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // not in STARTING or RUNNING status.
82a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // This returns false if stopping a worker fails immediately, e.g. when
83a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // IPC couldn't be sent to the worker.
845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ServiceWorkerStatusCode Stop();
855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Sends |message| to the embedded worker running in the child process.
875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // It is invalid to call this while the worker is not in RUNNING status.
885c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  ServiceWorkerStatusCode SendMessage(const IPC::Message& message);
89a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
90a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Add or remove |process_id| to the internal process set where this
91a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // worker can be started.
92a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void AddProcessReference(int process_id);
93a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void ReleaseProcessReference(int process_id);
94a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  bool HasProcessToRun() const { return !process_refs_.empty(); }
95a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
96a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  int embedded_worker_id() const { return embedded_worker_id_; }
97a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  Status status() const { return status_; }
98a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  int process_id() const { return process_id_; }
99a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  int thread_id() const { return thread_id_; }
1005c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  int worker_devtools_agent_route_id() const {
1015c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu    return worker_devtools_agent_route_id_;
1025c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  }
103a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
1040529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  void AddListener(Listener* listener);
1050529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  void RemoveListener(Listener* listener);
1065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
107a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) private:
1080529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  typedef ObserverList<Listener> ListenerList;
1090529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch
110a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  friend class EmbeddedWorkerRegistry;
111a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerInstanceTest, StartAndStop);
112cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerInstanceTest, SortProcesses);
113a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
114a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  typedef std::map<int, int> ProcessRefMap;
115a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
116a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Constructor is called via EmbeddedWorkerRegistry::CreateWorker().
117a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // This instance holds a ref of |registry|.
118cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  EmbeddedWorkerInstance(base::WeakPtr<ServiceWorkerContextCore> context,
119a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                         int embedded_worker_id);
120a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
121cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // Called back from ServiceWorkerProcessManager after Start() passes control
122cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // to the UI thread to acquire a reference to the process.
123cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  static void RunProcessAllocated(
124cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)      base::WeakPtr<EmbeddedWorkerInstance> instance,
125cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)      base::WeakPtr<ServiceWorkerContextCore> context,
126cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)      scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
127cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)      const EmbeddedWorkerInstance::StatusCallback& callback,
128cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)      ServiceWorkerStatusCode status,
129cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)      int process_id);
130cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void ProcessAllocated(scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
131cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                        const StatusCallback& callback,
132cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                        int process_id,
133cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                        ServiceWorkerStatusCode status);
134cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // Called back after ProcessAllocated() passes control to the UI thread to
135cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // register to WorkerDevToolsManager.
136cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void SendStartWorker(scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
137cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                       const StatusCallback& callback,
138cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                       int worker_devtools_agent_route_id,
139cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                       bool pause_on_start);
1405c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
141a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Called back from Registry when the worker instance has ack'ed that
142010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // it finished loading the script.
143010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  void OnScriptLoaded();
144010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
145010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // Called back from Registry when the worker instance has ack'ed that
146010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // it failed to load the script.
147010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  void OnScriptLoadFailed();
148010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
149010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // Called back from Registry when the worker instance has ack'ed that
150010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // its WorkerGlobalScope is actually started and parsed on |thread_id| in the
151a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // child process.
152a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // This will change the internal status from STARTING to RUNNING.
153a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void OnStarted(int thread_id);
154a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
155a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Called back from Registry when the worker instance has ack'ed that
156a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // its WorkerGlobalScope is actually stopped in the child process.
157a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // This will change the internal status from STARTING or RUNNING to
158a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // STOPPED.
159a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void OnStopped();
160a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
1615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Called back from Registry when the worker instance sends message
1625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // to the browser (i.e. EmbeddedWorker observers).
1630529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // Returns false if the message is not handled.
1640529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  bool OnMessageReceived(const IPC::Message& message);
1650529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch
1660529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // Called back from Registry when the worker instance reports the exception.
1670529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  void OnReportException(const base::string16& error_message,
1680529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                         int line_number,
1690529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                         int column_number,
1700529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                         const GURL& source_url);
1710529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch
1720529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // Called back from Registry when the worker instance reports to the console.
1730529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  void OnReportConsoleMessage(int source_identifier,
1740529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                              int message_level,
1750529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                              const base::string16& message,
1760529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                              int line_number,
1770529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                              const GURL& source_url);
1785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1795c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // Chooses a list of processes to try to start this worker in, ordered by how
1805c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // many clients are currently in those processes.
1815c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  std::vector<int> SortProcesses(
1825c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu      const std::vector<int>& possible_process_ids) const;
183a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
184cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  base::WeakPtr<ServiceWorkerContextCore> context_;
185a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  scoped_refptr<EmbeddedWorkerRegistry> registry_;
186a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  const int embedded_worker_id_;
187a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  Status status_;
188a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
189a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Current running information. -1 indicates the worker is not running.
190a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  int process_id_;
191a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  int thread_id_;
1925c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  int worker_devtools_agent_route_id_;
193a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
194a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  ProcessRefMap process_refs_;
1950529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  ListenerList listener_list_;
196a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
197cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_;
198cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
199a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance);
200a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)};
201a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
202a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}  // namespace content
203a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
204a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#endif  // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
205