Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: chrome/common/app_cache/app_cache_context_impl.cc

Issue 9712: AppCachePlumbing (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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 #include "chrome/common/app_cache/app_cache_context_impl.h"
6
7 #include "base/logging.h"
8 #include "chrome/common/render_messages.h"
9 #include "chrome/common/child_thread.h"
10 #include "googleurl/src/gurl.h"
11
12 IDMap<AppCacheContextImpl> AppCacheContextImpl::all_contexts;
13
14 // static
15 AppCacheContextImpl* AppCacheContextImpl::FromContextId(int id) {
16 return all_contexts.Lookup(id);
17 }
18
19 AppCacheContextImpl::AppCacheContextImpl(IPC::Message::Sender *sender)
20 : context_id_(kNoAppCacheContextId),
21 app_cache_id_(kUnknownAppCacheId),
22 pending_select_request_id_(0),
23 sender_(sender) {
24 DCHECK(sender_);
25 }
26
27 AppCacheContextImpl::~AppCacheContextImpl() {
28 UnInitializeContext();
29 }
30
31 void AppCacheContextImpl::Initialize(ContextType context_type,
32 WebAppCacheContext *parent) {
33 DCHECK(context_id_ == kNoAppCacheContextId);
34 DCHECK(((context_type == MAIN_FRAME) && !parent) ||
35 ((context_type != MAIN_FRAME) && parent));
36
37 context_id_ = all_contexts.Add(this);
38 CHECK(context_id_ != kNoAppCacheContextId);
39
40 sender_->Send(new AppCacheMsg_ContextCreated(context_type,
41 context_id_,
42 parent ? parent->context_id()
43 : kNoAppCacheContextId));
44 }
45
46 void AppCacheContextImpl::UnInitializeContext() {
47 if (context_id_ != kNoAppCacheContextId) {
48 sender_->Send(new AppCacheMsg_ContextDestroyed(context_id_));
49 all_contexts.Remove(context_id_);
50 context_id_ = kNoAppCacheContextId;
51 }
52 }
53
54 void AppCacheContextImpl::SelectAppCacheWithoutManifest(
55 const GURL &document_url,
56 int64 cache_document_was_loaded_from) {
57 DCHECK(context_id_ != kNoAppCacheContextId);
58 app_cache_id_ = kUnknownAppCacheId; // unknown until we get a response
59 sender_->Send(new AppCacheMsg_SelectAppCache(
60 context_id_, ++pending_select_request_id_,
61 document_url, cache_document_was_loaded_from,
62 GURL::EmptyGURL()));
63 }
64
65 void AppCacheContextImpl::SelectAppCacheWithManifest(
66 const GURL &document_url,
67 int64 cache_document_was_loaded_from,
68 const GURL &manifest_url) {
69 DCHECK(context_id_ != kNoAppCacheContextId);
70 app_cache_id_ = kUnknownAppCacheId; // unknown until we get a response
71 sender_->Send(new AppCacheMsg_SelectAppCache(
72 context_id_, ++pending_select_request_id_,
73 document_url, cache_document_was_loaded_from,
74 manifest_url));
75 }
76
77 void AppCacheContextImpl::OnAppCacheSelected(int select_request_id,
78 int64 app_cache_id) {
79 if (select_request_id == pending_select_request_id_) {
80 DCHECK(app_cache_id_ == kUnknownAppCacheId);
81 DCHECK(app_cache_id != kUnknownAppCacheId);
82 app_cache_id_ = app_cache_id;
83 }
84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698