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

Side by Side Diff: content/browser/appcache/appcache_navigation_handle.h

Issue 2501343003: PlzNavigate: AppCache support. (Closed)
Patch Set: Address review comments Created 4 years 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
OLDNEW
(Empty)
1 // Copyright 2016 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 CONTENT_BROWSER_APPCACHE_APPCACHE_NAVIGATION_HANDLE_H_
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_NAVIGATION_HANDLE_H_
7
8 #include <memory>
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12
13 namespace content {
14
15 class AppCacheNavigationHandleCore;
16 class ChromeAppCacheService;
17
18 // This class is used to manage the lifetime of AppCacheHosts created during
19 // navigation. This is a UI thread class, with a pendant class on the IO
20 // thread, the AppCacheNavigationHandleCore.
21 //
22 // The lifetime of the AppCacheNavigationHandle, the
23 // AppCacheNavigationHandleCore and the AppCacheHost are the following :
24 // 1) We create a AppCacheNavigationHandle on the UI thread with a
25 // app cache host id of -1. This also leads to the creation of a
26 // AppCacheNavigationHandleCore with an id of -1. Every time
27 // an AppCacheNavigationHandle instance is created the global host id is
28 // decremented by 1.
29 //
30 // 2) When the navigation request is sent to the IO thread, we include a
31 // pointer to the AppCacheNavigationHandleCore.
32 //
33 // 3. The AppCacheHost instance is created and its ownership is passed to the
34 // AppCacheNavigationHandleCore instance. Now the app cache host id is
35 // updated.
36 //
37 // 4) The AppCacheNavigationHandleCore instance informs the
38 // AppCacheNavigationHandle instance on the UI thread that the app cache
39 // host id was updated.
40 //
41 // 5) When the navigation is ready to commit, the NavigationRequest will
42 // update the RequestNavigationParams based on the id from the
43 // AppCacheNavigationHandle.
44 //
45 // 6. The commit leads to AppCache registrations happening from the renderer.
46 // This is via the IPC message AppCacheHostMsg_RegisterHost. The
47 // AppCacheDispatcherHost class which handles these IPCs will be informed
48 // about these hosts when the navigation commits. It will ignore the
49 // host registrations as they have already been registered. The
50 // ownership of the AppCacheHost is passed from the
51 // AppCacheNavigationHandle core to the AppCacheBackend.
52
53 // 7) When the navigation finishes, the AppCacheNavigationHandle is
54 // destroyed. The destructor of the AppCacheNavigationHandle posts a
55 // task to destroy the AppacheNavigationHandleCore on the IO thread.
56
57 class AppCacheNavigationHandle {
58 public:
59 AppCacheNavigationHandle(ChromeAppCacheService* appcache_service);
60 ~AppCacheNavigationHandle();
61
62 int appcache_host_id() const { return appcache_host_id_; }
63 AppCacheNavigationHandleCore* core() const { return core_.get(); }
64
65 // Called when a navigation is committed. The |process_id| parameter is
66 // is the process id of the renderer.
67 void CommitNavigation(int process_id);
68
69 private:
70 int appcache_host_id_;
71 std::unique_ptr<AppCacheNavigationHandleCore> core_;
72 base::WeakPtrFactory<AppCacheNavigationHandle> weak_factory_;
73
74 DISALLOW_COPY_AND_ASSIGN(AppCacheNavigationHandle);
75 };
76
77 } // namespace content
78
79 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_NAVIGATION_HANDLE_H_
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_interceptor.cc ('k') | content/browser/appcache/appcache_navigation_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698