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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
// Copyright (c) 2010 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_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_
#define CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_
#include "base/hash_tables.h"
#include "base/process.h"
#include "base/ref_counted.h"
#include "base/string16.h"
#include "chrome/common/content_settings.h"
#include "ipc/ipc_message.h"
#include "webkit/database/database_connections.h"
#include "webkit/database/database_tracker.h"
class GURL;
class HostContentSettingsMap;
class Receiver;
class ResourceMessageFilter;
class DatabaseDispatcherHost
: public base::RefCountedThreadSafe<DatabaseDispatcherHost>,
public webkit_database::DatabaseTracker::Observer {
public:
DatabaseDispatcherHost(webkit_database::DatabaseTracker* db_tracker,
ResourceMessageFilter* resource_message_filter);
void Init(base::ProcessHandle process_handle);
void Shutdown();
bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok);
// VFS message handlers (IO thread)
void OnDatabaseOpenFile(const string16& vfs_file_name,
int desired_flags,
int32 message_id);
void OnDatabaseDeleteFile(const string16& vfs_file_name,
const bool& sync_dir,
int32 message_id);
void OnDatabaseGetFileAttributes(const string16& vfs_file_name,
int32 message_id);
void OnDatabaseGetFileSize(const string16& vfs_file_name,
int32 message_id);
// Database tracker message handlers (IO thread)
void OnDatabaseOpened(const string16& origin_identifier,
const string16& database_name,
const string16& description,
int64 estimated_size);
void OnDatabaseModified(const string16& origin_identifier,
const string16& database_name);
void OnDatabaseClosed(const string16& origin_identifier,
const string16& database_name);
void OnAllowDatabase(const std::string& origin_url,
const string16& name,
const string16& display_name,
unsigned long estimated_size,
IPC::Message* reply_msg);
// DatabaseTracker::Observer callbacks (file thread)
virtual void OnDatabaseSizeChanged(const string16& origin_identifier,
const string16& database_name,
int64 database_size,
int64 space_available);
virtual void OnDatabaseScheduledForDeletion(const string16& origin_identifier,
const string16& database_name);
void Send(IPC::Message* message);
private:
class PromptDelegate;
void AddObserver();
void RemoveObserver();
void ReceivedBadMessage(uint32 msg_type);
// VFS message handlers (file thread)
void DatabaseOpenFile(const string16& vfs_file_name,
int desired_flags,
int32 message_id);
void DatabaseDeleteFile(const string16& vfs_file_name,
bool sync_dir,
int32 message_id,
int reschedule_count);
void DatabaseGetFileAttributes(const string16& vfs_file_name,
int32 message_id);
void DatabaseGetFileSize(const string16& vfs_file_name,
int32 message_id);
// Database tracker message handlers (file thread)
void DatabaseOpened(const string16& origin_identifier,
const string16& database_name,
const string16& description,
int64 estimated_size);
void DatabaseModified(const string16& origin_identifier,
const string16& database_name);
void DatabaseClosed(const string16& origin_identifier,
const string16& database_name);
// CookiePromptModalDialog response handler (io thread)
void AllowDatabaseResponse(IPC::Message* reply_msg,
ContentSetting content_setting);
// The database tracker for the current profile.
scoped_refptr<webkit_database::DatabaseTracker> db_tracker_;
// The resource message filter that owns us.
ResourceMessageFilter* resource_message_filter_;
// The handle of this process.
base::ProcessHandle process_handle_;
// True if and only if this instance was added as an observer
// to DatabaseTracker.
bool observer_added_;
// If true, all messages that are normally processed by this class
// will be silently discarded. This field should be set to true
// only when the corresponding renderer process is about to go away.
bool shutdown_;
// Keeps track of all DB connections opened by this renderer
webkit_database::DatabaseConnections database_connections_;
};
#endif // CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_
|