| OLD | NEW | 
| (Empty) |  | 
 |   1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 
 |   2 // Use of this source code is governed by a BSD-style license that can be | 
 |   3 // found in the LICENSE file. | 
 |   4  | 
 |   5 #ifndef CHROME_WORKER_WEBWORKERCLIENT_PROXY_H_ | 
 |   6 #define CHROME_WORKER_WEBWORKERCLIENT_PROXY_H_ | 
 |   7  | 
 |   8 #include <vector> | 
 |   9  | 
 |  10 #include "base/basictypes.h" | 
 |  11 #include "base/scoped_ptr.h" | 
 |  12 #include "chrome/common/ipc_channel.h" | 
 |  13 #include "googleurl/src/gurl.h" | 
 |  14 #include "webkit/glue/webworkerclient.h" | 
 |  15  | 
 |  16 class WebWorker; | 
 |  17  | 
 |  18 // This class receives IPCs from the renderer and calls the WebCore::Worker | 
 |  19 // implementation (after the data types have been converted by glue code).  It | 
 |  20 // is also called by the worker code and converts these function calls into | 
 |  21 // IPCs that are sent to the renderer, where they're converted back to function | 
 |  22 // calls by WebWorkerProxy. | 
 |  23 class WebWorkerClientProxy : public WebWorkerClient, | 
 |  24                              public IPC::Channel::Listener { | 
 |  25  public: | 
 |  26   WebWorkerClientProxy (const GURL& url, int route_id); | 
 |  27   ~WebWorkerClientProxy (); | 
 |  28  | 
 |  29   // WebWorkerClient implementation. | 
 |  30   void PostMessageToWorkerObject(const string16& message); | 
 |  31   void PostExceptionToWorkerObject( | 
 |  32       const string16& error_message, | 
 |  33       int line_number, | 
 |  34       const string16& source_url); | 
 |  35   void PostConsoleMessageToWorkerObject( | 
 |  36       int destination, | 
 |  37       int source, | 
 |  38       int level, | 
 |  39       const string16& message, | 
 |  40       int line_number, | 
 |  41       const string16& source_url); | 
 |  42   void ConfirmMessageFromWorkerObject(bool has_pending_activity); | 
 |  43   void ReportPendingActivity(bool has_pending_activity); | 
 |  44   void WorkerContextDestroyed(); | 
 |  45  | 
 |  46   // IPC::Channel::Listener implementation. | 
 |  47   void OnMessageReceived(const IPC::Message& message); | 
 |  48  | 
 |  49  private: | 
 |  50   bool Send(IPC::Message* message); | 
 |  51  | 
 |  52   // The source url for this worker. | 
 |  53   GURL url_; | 
 |  54  | 
 |  55   int route_id_; | 
 |  56  | 
 |  57   // Whether we've received StartWorkerContext message. | 
 |  58   bool started_worker_; | 
 |  59  | 
 |  60   scoped_ptr<WebWorker> impl_; | 
 |  61  | 
 |  62   // Stores messages that arrived before the StartWorkerContext message. | 
 |  63   std::vector<IPC::Message*> queued_messages_; | 
 |  64  | 
 |  65   DISALLOW_COPY_AND_ASSIGN(WebWorkerClientProxy); | 
 |  66 }; | 
 |  67  | 
 |  68 #endif  // CHROME_WORKER_WEBWORKERCLIENT_PROXY_H_ | 
| OLD | NEW |