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

Side by Side Diff: sky/engine/core/fetch/ResourceLoader.h

Issue 1223793006: Delete sky/engine/core/fetch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « sky/engine/core/fetch/ResourceFetcher.cpp ('k') | sky/engine/core/fetch/ResourceLoader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2005, 2006, 2011 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef SKY_ENGINE_CORE_FETCH_RESOURCELOADER_H_
30 #define SKY_ENGINE_CORE_FETCH_RESOURCELOADER_H_
31
32 #include "sky/engine/core/fetch/ResourceLoaderOptions.h"
33 #include "sky/engine/platform/network/ResourceRequest.h"
34 #include "sky/engine/public/platform/WebURLLoader.h"
35 #include "sky/engine/public/platform/WebURLLoaderClient.h"
36 #include "sky/engine/wtf/Forward.h"
37 #include "sky/engine/wtf/RefCounted.h"
38
39 namespace blink {
40
41 class Resource;
42 class KURL;
43 class ResourceError;
44 class ResourceResponse;
45 class ResourceLoaderHost;
46
47 class ResourceLoader final : public RefCounted<ResourceLoader>, protected WebURL LoaderClient {
48 public:
49 static PassRefPtr<ResourceLoader> create(ResourceLoaderHost*, Resource*, con st ResourceRequest&, const ResourceLoaderOptions&);
50 virtual ~ResourceLoader();
51
52 void start();
53
54 void cancel();
55 void cancel(const ResourceError&);
56 void cancelIfNotFinishing();
57
58 Resource* cachedResource() { return m_resource; }
59
60 void releaseResources();
61
62 void didChangePriority(ResourceLoadPriority, int intraPriorityValue);
63
64 // WebURLLoaderClient
65 virtual void willSendRequest(blink::WebURLLoader*, blink::WebURLRequest&, co nst blink::WebURLResponse& redirectResponse) override;
66 virtual void didSendData(blink::WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override;
67 virtual void didReceiveResponse(blink::WebURLLoader*, const blink::WebURLRes ponse&) override;
68 virtual void didReceiveData(blink::WebURLLoader*, const char*, int, int enco dedDataLength) override;
69 virtual void didFinishLoading(blink::WebURLLoader*, double finishTime, int64 encodedDataLength) override;
70 virtual void didFail(blink::WebURLLoader*, const blink::WebURLError&) overri de;
71 virtual void didDownloadData(blink::WebURLLoader*, int, int) override;
72
73 const KURL& url() const { return m_request.url(); }
74 bool isLoadedBy(ResourceLoaderHost*) const;
75
76 bool reachedTerminalState() const { return m_state == Terminated; }
77 const ResourceRequest& request() const { return m_request; }
78
79 class RequestCountTracker {
80 public:
81 RequestCountTracker(ResourceLoaderHost*, Resource*);
82 RequestCountTracker(const RequestCountTracker&);
83 ~RequestCountTracker();
84 private:
85 ResourceLoaderHost* m_host;
86 Resource* m_resource;
87 };
88
89 private:
90 ResourceLoader(ResourceLoaderHost*, Resource*, const ResourceLoaderOptions&) ;
91
92 void init(const ResourceRequest&);
93
94 void didFinishLoadingOnePart(double finishTime, int64_t encodedDataLength);
95
96 ResourceRequest& applyOptions(ResourceRequest&) const;
97
98 OwnPtr<blink::WebURLLoader> m_loader;
99 RefPtr<ResourceLoaderHost> m_host;
100
101 ResourceRequest m_request;
102
103 bool m_notifiedLoadComplete;
104
105 ResourceLoaderOptions m_options;
106
107 enum ResourceLoaderState {
108 Initialized,
109 Finishing,
110 Terminated
111 };
112
113 enum ConnectionState {
114 ConnectionStateNew,
115 ConnectionStateStarted,
116 ConnectionStateReceivedResponse,
117 ConnectionStateReceivingData,
118 ConnectionStateFinishedLoading,
119 ConnectionStateCanceled,
120 ConnectionStateFailed,
121 };
122
123 RawPtr<Resource> m_resource;
124 ResourceLoaderState m_state;
125
126 // Used for sanity checking to make sure we don't experience illegal state
127 // transitions.
128 ConnectionState m_connectionState;
129
130 OwnPtr<RequestCountTracker> m_requestCountTracker;
131 };
132
133 }
134
135 #endif // SKY_ENGINE_CORE_FETCH_RESOURCELOADER_H_
OLDNEW
« no previous file with comments | « sky/engine/core/fetch/ResourceFetcher.cpp ('k') | sky/engine/core/fetch/ResourceLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698