Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / browser / devtools / devtools_browser_target.h
blob46ed291cfd7521e6b92a71eb42bf98a6f79fbc27
1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BROWSER_TARGET_H_
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BROWSER_TARGET_H_
8 #include <map>
9 #include <set>
10 #include <string>
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h"
16 #include "base/stl_util.h"
17 #include "content/browser/devtools/devtools_protocol.h"
19 namespace base {
20 class DictionaryValue;
21 class MessageLoopProxy;
22 class Value;
23 } // namespace base
25 namespace net {
26 class HttpServer;
27 } // namespace net
29 namespace content {
31 // This class handles the "Browser" target for remote debugging.
32 class DevToolsBrowserTarget
33 : public base::RefCountedThreadSafe<DevToolsBrowserTarget> {
34 public:
35 DevToolsBrowserTarget(base::MessageLoopProxy* message_loop_proxy,
36 net::HttpServer* server,
37 int connection_id);
39 int connection_id() const { return connection_id_; }
41 // Takes ownership of |handler|.
42 void RegisterDomainHandler(const std::string& domain,
43 DevToolsProtocol::Handler* handler,
44 bool handle_on_ui_thread);
46 void HandleMessage(const std::string& data);
48 void Detach();
50 private:
51 friend class base::RefCountedThreadSafe<DevToolsBrowserTarget>;
52 ~DevToolsBrowserTarget();
54 void HandleCommandOnUIThread(
55 DevToolsProtocol::Handler*,
56 scoped_refptr<DevToolsProtocol::Command> command);
58 void DeleteHandlersOnUIThread(
59 std::vector<DevToolsProtocol::Handler*> handlers);
61 void Respond(const std::string& message);
62 void RespondFromUIThread(const std::string& message);
64 base::MessageLoopProxy* message_loop_proxy_;
65 net::HttpServer* http_server_;
66 const int connection_id_;
68 typedef std::map<std::string, DevToolsProtocol::Handler*> DomainHandlerMap;
69 DomainHandlerMap handlers_;
70 STLValueDeleter<DomainHandlerMap> handlers_deleter_;
71 std::set<std::string> handle_on_ui_thread_;
72 base::WeakPtrFactory<DevToolsBrowserTarget> weak_factory_;
74 DISALLOW_COPY_AND_ASSIGN(DevToolsBrowserTarget);
77 } // namespace content
79 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BROWSER_TARGET_H_