MCPcopy Index your code
hub / github.com/NASAWorldWind/WorldWindJava / resolve

Method resolve

lib-external/webview/windows/WebResourceResolver.cpp:85–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85HRESULT WebResourceResolver::resolve(const wchar_t *address, wchar_t *result, DWORD *chResult) const
86{
87 HRESULT ret = S_OK;
88 JNIEnv *env = NULL;
89
90 if (address == NULL || result == NULL || chResult == NULL)
91 return E_POINTER;
92
93 *result = NULL;
94
95 // Attach to the Java thread
96 jint err = javaVM->AttachCurrentThread((void**)&env, NULL);
97 if (err != JNI_OK)
98 {
99 Logging::logger()->severe(L"NativeLib.FailedToAttachToVM");
100 ret = E_UNEXPECTED;
101 goto cleanup;
102 }
103
104 jstring jAddress = env->NewString(reinterpret_cast<const jchar*>(address), static_cast<jsize>(wcslen(address)));
105 if (jAddress == NULL)
106 {
107 ret = E_OUTOFMEMORY;
108 goto cleanup;
109 }
110
111 // Invoke resolve
112 jobject url = env->CallObjectMethod(this->jObject, WebResourceResolver_resolve, jAddress);
113
114 jstring urlStr = NULL;
115 const jchar *urlChars;
116 if (url != NULL)
117 {
118 // Convert URL to string
119 urlStr = reinterpret_cast<jstring>(env->CallObjectMethod(url, Object_toString));
120
121 urlChars = env->GetStringChars(urlStr, NULL);
122 jsize len = env->GetStringLength(urlStr);
123
124 if (static_cast<DWORD>(len) + 1 <= *chResult) // Cast to DWORD to avoid signed/unsigned comparison. len is string length, which will never be negative
125 {
126 wcscpy_s(result, *chResult, reinterpret_cast<const wchar_t*>(urlChars));
127 }
128 else
129 {
130 ret = S_FALSE;
131 *chResult = static_cast<DWORD>(len) + 1;
132 }
133 }
134
135cleanup:
136 if (urlStr)
137 env->ReleaseStringChars(urlStr, urlChars);
138
139 javaVM->DetachCurrentThread();
140
141 return ret;
142}

Callers

nothing calls this directly

Calls 1

severeMethod · 0.80

Tested by

no test coverage detected