Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / browser / worker_host / worker_document_set.cc
blob48eaf867c23628b0a29c58c728fcf7f0fb3b0f46
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.
5 #include "content/browser/worker_host/worker_document_set.h"
7 #include "base/logging.h"
9 namespace content {
11 WorkerDocumentSet::WorkerDocumentSet() {
14 void WorkerDocumentSet::Add(WorkerMessageFilter* parent,
15 unsigned long long document_id,
16 int render_process_id,
17 int render_view_id) {
18 DocumentInfo info(parent, document_id, render_process_id, render_view_id);
19 document_set_.insert(info);
22 bool WorkerDocumentSet::Contains(WorkerMessageFilter* parent,
23 unsigned long long document_id) const {
24 for (DocumentInfoSet::const_iterator i = document_set_.begin();
25 i != document_set_.end(); ++i) {
26 if (i->filter() == parent && i->document_id() == document_id)
27 return true;
29 return false;
32 void WorkerDocumentSet::Remove(WorkerMessageFilter* parent,
33 unsigned long long document_id) {
34 for (DocumentInfoSet::iterator i = document_set_.begin();
35 i != document_set_.end(); i++) {
36 if (i->filter() == parent && i->document_id() == document_id) {
37 document_set_.erase(i);
38 break;
41 // Should not be duplicate copies in the document set.
42 DCHECK(!Contains(parent, document_id));
45 void WorkerDocumentSet::RemoveAll(WorkerMessageFilter* parent) {
46 for (DocumentInfoSet::iterator i = document_set_.begin();
47 i != document_set_.end();) {
49 // Note this idiom is somewhat tricky - calling document_set_.erase(iter)
50 // invalidates any iterators that point to the element being removed, so
51 // bump the iterator beyond the item being removed before calling erase.
52 if (i->filter() == parent) {
53 DocumentInfoSet::iterator item_to_delete = i++;
54 document_set_.erase(item_to_delete);
55 } else {
56 ++i;
61 WorkerDocumentSet::DocumentInfo::DocumentInfo(
62 WorkerMessageFilter* filter, unsigned long long document_id,
63 int render_process_id, int render_view_id)
64 : filter_(filter),
65 document_id_(document_id),
66 render_process_id_(render_process_id),
67 render_view_id_(render_view_id) {
70 WorkerDocumentSet::~WorkerDocumentSet() {
73 } // namespace content